Posted on 2009-02-16 20:02
啥都写点 阅读(197)
评论(0) 编辑 收藏 所属分类:
J2EE
àOpenSessionInViewFilter
* 这是为了避免Hibernate的懒加载异常而创建的解决方案
* 它是一个过滤器,能够让Session在请求解释完成之后再关闭(所以才能够避免懒加载异常)
* 配置方式是,在web.xml中定义过滤器即可:
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
àCharacterEncodingFilter
* 如何提交中文字符?
* 配置web.xml了,Spring提供了专门的针对Encoding的过滤器
* 配置方法如下:
<filter>
<filter-name>Spring character encoding filter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Spring character encoding filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-- 学海无涯