SSH对于web.xml的配置

来源:互联网 发布:通信网络设计师是什么 编辑:程序博客网 时间:2024/05/21 09:30

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

1 0
原创粉丝点击