<!--以下是由Spring提供的filter来解决Struts乱码问题 -->
< 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 >
<!-- 解决乱码 -->
< 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 >
< 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 >
<!-- 解决乱码 -->
<!-- 使用Spring解决Hiberante因session关闭导致的延迟例外问题 -->
Hibernate 允许对关联对象、属性进行延迟加载,但是必须保证延迟加载的操作限于同一个 Hibernate Session 范围之内进行。如果 Service 层返回一个启用了延迟加载功能的领域对象给 Web 层,当 Web 层访问到那些需要延迟加载的数据时,由于加载领域对象的 Hibernate Session 已经关闭,这些导致延迟加载数据的访问异常
用来把一个Hibernate Session和一次完整的请求过程对应的线程相绑定。目的是为了实现"Open Session in View"的模式。例如: 它允许在事务提交之后延迟加载显示所需要的对象。
< 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 >