1.Spring中专门提供了处理乱码的问题的解决方案:在web.xml文件中添加下面的过滤器:
<!-- spring中提供的解决乱码问题 -->
<filter>
<filter-name>encoding</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>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2.spring提供的,hibernate中因session关闭导致的延迟加载例外问题解决方案:同样是将下面的过滤器添加在web.xml文件中
<!--spring提供的解决,hibernate中因session关闭导致的延迟加载例外问题 -->
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
网友评论