web.xml完整配置
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="WebApp_1227143028044" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <!-- 加载Spring服务 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:/spring-dataSource.xml, classpath:/spring-data.xml, classpath:/spring-server.xml, /WEB-INF/applicationContext-*.xml </param-value> </context-param> <!-- 加载log4j --> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:/log4j.properties</param-value> </context-param> <context-param> <param-name>webAppRootKey</param-name> <param-value>netctoss.root</param-value> </context-param> <!--处理请求编码格式--> <filter> <filter-name>encodingFilter</filter-name> <filter-class> org.springframework.web.filter.CharacterEncodingFilter </filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <!-- 自定义过滤器测试 --> <filter> <filter-name>adminFilter</filter-name> <filter-class>com.ghrt.common.AdminFilter</filter-class> </filter> <filter-mapping> <filter-name>adminFilter</filter-name> <url-pattern>/admin/*</url-pattern> </filter-mapping> <!-- 监听Log4j --> <listener> <listener-class> org.springframework.web.util.Log4jConfigListener </listener-class> </listener> <!-- 监听Spring文件 --> <servlet> <servlet-name>SpringContextServlet</servlet-name> <servlet-class> org.springframework.web.context.ContextLoaderServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!--或 --> <!-- <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> --> <!-- 配置dwr --> <servlet> <servlet-name>dwr-invoker</servlet-name> <servlet-class> org.directwebremoting.servlet.DwrServlet </servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet> <servlet-name>action</servlet-name> <servlet-class> org.apache.struts.action.ActionServlet </servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>3</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>3</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet> <description> This is the description of my J2EE component </description> <display-name> This is the display name of my J2EE component </display-name> <servlet-name>Image</servlet-name> <servlet-class>com.ghrt.common.Image</servlet-class> </servlet> <!-- eWebEditor 配置 --> <display-name>defaultroot</display-name> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Image</servlet-name> <url-pattern>/servlet/Image</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>dwr-invoker</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> <!-- 加载核心标签库 --> <jsp-config> <taglib> <taglib-uri> http://www.java.sun.com/jsp/jstl/core </taglib-uri> <taglib-location>/WEB-INF/jstl/c.tld</taglib-location> </taglib> </jsp-config> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <error-page> <error-code>404</error-code> <location>/404.jsp</location> </error-page> <error-page> <error-code>503</error-code> <location>/500.jsp</location> </error-page> <error-page> <error-code>500</error-code> <location>/500.jsp</location> </error-page> </web-app>
转自:http://blog.sina.com.cn/s/blog_451f596201014z5h.html