这是一个web.xml文件 的 详解 一般在项目运行时先加载web.xml文件 然后 如下 :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<display-name>project-ssi2</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value> 1 在这里加载spring容器
classpath*:/configs/spring/applicationContext.xml,
classpath*:/configs/spring/applicationContext*.xml
</param-value>
</context-param>
<welcome-file-list> 2 这里是欢迎界面 项目运行后的第一个页面
<welcome-file>/modules/index.jsp</welcome-file>
</welcome-file-list>
<filter> 3 过滤器 这里是编码格式 过滤器
<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>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter> 4 报表的 过滤器
<filter-name>sitemesh</filter-name>
<filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2Filter</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping> 5 这里是 struts2 的过滤器 将所有的 action 全都 在这里过滤通过
<filter-name>struts2Filter</filter-name>
<url-pattern>*.action</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>struts2Filter</filter-name>
<url-pattern>*.jsp</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<jsp-config>
<taglib>
<taglib-uri>http://jsptags.com/tags/navigation/pager</taglib-uri>
<taglib-location>/WEB-INF/tags/pager-taglib.tld</taglib-location>
</taglib>
</jsp-config>
<listener> 6 监听器 这里是最高权限的监听器
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<error-page> 7 错误的情况 。以及各个路径 。
<exception-type>java.lang.Throwable</exception-type>
<location>/modules/common/error/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/modules/common/error/error.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/modules/common/error/error_404.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/modules/common/error/error.jsp</location>
</error-page>
</web-app>