读书人

懒加载错误:LazyInitializationExcept

发布时间: 2012-09-25 09:55:58 作者: rapoo

懒加载异常:LazyInitializationException: could not initialize proxy-no session
这是Session关闭了,你又去使用Session去执行别的操作,你可以设置lazy="false"也可以如下:
1.看web.xml中的OpenSessionInViewFilter是否配置。

<filter>
<filter-name>openSession</filter-name>
<filter-class>
org.spingframework.orm.hibernate3.support.OpenSessionInViewfilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>openSession</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
2.有可能是其顺序颠倒。
***3.看是否经过重定向,重定向是两次请求,就是打开了一个新的Session。

读书人网 >软件架构设计

热点推荐