首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

servlet tomcat web.xml配备信息说明

2012-07-25 
servlet tomcat web.xml配置信息说明过滤器:?1.类型配置1[解决请求期间,数据库session关闭的异常]?下面这

servlet tomcat web.xml配置信息说明

过滤器:

?

1.类型配置1[解决请求期间,数据库session关闭的异常]

?

下面这个过滤器是针对JPA中在配置中设置了延迟加载属性,导致在request请求期间,数据库session关闭的解决方案

<!-- OpenEntityManagerInViewFilter -->
??? <filter id="springOpenEntityManagerInViewFilter">
??? ??? <filter-name>springOpenEntityManagerInViewFilter</filter-name>
??? ??? <filter-class>
??? ??? ??? org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>

下面这个过滤器是针对Hibernate中在配置中设置了延迟加载属性,导致在request请求期间,数据库session关闭的解决方案


<!-- OpenSessionInView -->??
??? < filter >??
??????? < filter-name > OpenSessionInViewFilter </ filter-name >??
??????? < filter-class >??
??????????? org.springframework.orm.hibernate3.support.OpenSessionInViewFilter?
??????? </ filter-class >??
??????? < init-param >??
??????????? < param-name > singleSession </ param-name >??
??????????? < param-value > true </ param-value >??
??????? </ init-param >??
??? </ filter >

?

?

2.解决编码的问题

?

<!-- Spring过滤中文字符集 -->??
??? < filter >??
??????? < filter-name > SetCharacterEncoding </ 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 >??
??? </ filter >

<!-- 要过滤得类型 -->??
??? < filter-mapping >??
??????? < filter-name > SetCharacterEncoding </ filter-name >??
??????? < url-pattern > *.jsp </ url-pattern >??
??? </ filter-mapping >??
??? < filter-mapping >??
??????? < filter-name > SetCharacterEncoding </ filter-name >??
??????? < url-pattern > *.do </ url-pattern >??
??? </ filter-mapping >

?

?

3.作用域过滤设置

?

<!-- 注册Spring的request作用域 -->??
??? < listener >??
??????? < listener-class >??
??????????? org.springframework.web.context.request.RequestContextListener?
??????? </ listener-class >??
??? </ listener >

?

<!--?
??????? request?
??????? request表示该针对每一次HTTP请求都会产生一个新的bean,同时该bean仅在当前HTTP request内有效,配置实例:?
??????? 可选的值有:request、session、global session??

-->

?

4.监听器配置

?

??? <context-param>
??? ??? <param-name>log4jRefreshInterval</param-name>
??? ??? <param-value>60000</param-value>
??? </context-param>
??? <listener>
??? ??? <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
??? </listener>

<--这个监听器是用来配置监听log4j的,就是说如果log4j.properties这个配置文件有些许的修改的,都会按照log4jRefreshInterval中配置的值就行重新加载!-->

?

?

热点排行