could not initialize proxy - no Session 的解决方法

could not initialize proxy - no Session 的解决方法

主要错误信息提示:

Stacktraces
org.apache.jasper.JasperException: could not initialize proxy - no Session - Class: org.hibernate.proxy.AbstractLazyInitializer File: AbstractLazyInitializer.java Method: initialize Line: 167 - org/hibernate/proxy/AbstractLazyInitializer.java:167:-1
could not initialize proxy - no Session - Class: org.hibernate.proxy.AbstractLazyInitializer File: AbstractLazyInitializer.java Method: initialize Line: 167 - org/hibernate/proxy/AbstractLazyInitializer.java:167:-1

      解决方法

                     在web.xml中加入一个filter

    <filter>
  <filter-name>openSessionInView</filter-name>
  <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
   <filter-mapping>
  <filter-name>openSessionInView</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

注意:此filter必须在struts的filter之前,否则会报错。
原因:在你访问之前,session已经关闭了。

你可能感兴趣的:(session)