web.xml集成Spring,Struts配置文件说明
2012-07-30 11:24 Patrick.Lee 阅读(1602) 评论(0) 编辑 收藏 举报<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!-- sesion过期时间为XX分种 -->
<session-config>
<session-timeout>
1
</session-timeout>
</session-config>
<!--加载spring配置由contextloaderListener负责读取application.xml -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- 如果没有context-param标签的话,contextLoaderListener就读取application.xml -->
<!-- 指定contextLoaderListener负责读取指定的配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/application-acl.xml,
/WEB-INF/config/application.xml
</param-value>
</context-param>
<!-- 加载log4j -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<contex-param>
<param-name>log4jConfigListener</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</contex-param>
<!-- ,它可以截取和修改进入一个servlert或jsp页面的请求,
或从一个servlet或jsp页面发出的响应,在执行一个一个servlet或jsp页面之前,
必须执行一个相关的过滤器的dofilter方法。
在该过滤器对其filterChain对象调用doFilter时,
执行链中的下一个过滤器,如果没有其它的过滤器,
servlet或jsp页面被执行。
过滤器具有对到来的ServletRequest请求对象的全部访问权 -->
<filter>
<filter-name>HttpSessionFilter</filter-name>
<filter-class>filter.HttpSessionFilter</filter-class>
<init-param>
<param-name>loginUrl</param-name>
<param-value>/login.do?method=index</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>HttpSessionFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<!-- 设置WEB应用字符集,也是通过过滤器完成的 -->
<filter>
<filter-name>CharacterEncodingFilter</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>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 指定action和印射URL Struts -->
<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/config/struts-config.xml</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>