1
我想使用OpenEntityManagerInViewFilter
能够避免lazyinitialization加载。这是我的web.xml配置:如何配置OpenEntityManagerInViewFilter Spring MVC
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/mvc-dispatcher-servlet.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
我仍然得到exeption:
Servlet.service()
对servlet的[mvc-dispatcher
]与路径方面[/ ...]抛出异常
Request processing failed; nested exception is
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ..., could not initialize proxy - no Session] with root cause
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ...., could not initialize proxy - no Session
有人知道我做错了什么?