1、针对Struts2的配置
<filter>
<filter-name>SSH_1</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SSH_1</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-class>
<url-pattern>
注册strtus2默认的过滤器,会过滤用户的请求。过滤哪些请求(过滤所有请求)
2、针对Spring的配置
<!-- Spring 监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
注册Spring默认的监听器,会自动转配applicationContext.xml配置信息到Spring容器(上下文)中。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
<!-- <param-value>/WEB-INF/applicationContext.xml</param-value> -->
</context-param>
applicationContext.xml源码中放在/WEB-INF/applicationContext.xml
,也可以放在其它位置
放在src下,则需要配置:classpath:applicationContext.xml。
3、针对日志管理log
<!--spring log4j监听器 -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!--log4j配置文件加载 -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<!--启动一个watchdog线程每1800秒扫描一下log4j配置文件的变化 -->
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>1800000</param-value>
</context-param>
Spring与log4j结合,具备打印日志的功能,首先配置Springlog4j监听器,然后加载log4j的配置文件(里面说明了要打印哪些内容以及打印日志存的目录),启动一个watchdog线程每1800秒扫描一下log4j配置文件的变化