在web.xml 文件下添加 OpenEntityManagerInViewFilter
错误原因 13:34:34,859 ERROR LazyInitializationException:42 - could not initialize proxy - no Session org.hibernate.LazyInitializationException: could not initialize proxy - no Session
解决方法 这里注意顺序。。必需放在之前(因为低层Filter 的原理是从上到下过滤的) <!-- OpenEntityManagerInViewFilter required prior to struts2-->
<!-- OpenEntityManagerInViewFilter required prior to struts2--> <filter> <filter-name>SpringOpenEntityManagerInViewFilter</filter-name> <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>SpringOpenEntityManagerInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Struts2 Filter --><filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping>
?