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配置文件的變化