在頁面上顯示員工信息,其中員工所屬部門需要關閉懶加載才能顯示。而用OpenSessionInViewFilter,剛打開頁面時可以看到
部門信息,刷新一下、點分頁的下一頁就沒了,再返回上一頁也沒了。只有在hibernate映射文件的把lazy改成false才能長久
管用。下面是web.xml文件,應該沒錯吧
<?xml?version="1.0"?encoding="UTF-8"?>
<web-app?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?xmlns="http://java.sun.com/xml/ns/javaee"?xsi:schemaLocation="http://java.sun.com/xml/ns/javaee?http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"?id="WebApp_ID"?version="3.0">
??
??<!--?spring的核心監聽器?-->
??<listener>
??????<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
??</listener>
??
??<context-param>
??????<param-name>contextConfigLocation</param-name>
??????<param-value>classpath:applicationContext.xml</param-value>
??</context-param>
??
??<filter>
??????<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>*.action</url-pattern>
??</filter-mapping>
??
??<!--?struts2核心過濾器的配置?-->
??<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>/*</url-pattern>
??</filter-mapping>
??
??<display-name>ssh_employee</display-name>
??<welcome-file-list>
????<welcome-file>index.html</welcome-file>
????<welcome-file>index.htm</welcome-file>
????<welcome-file>index.jsp</welcome-file>
????<welcome-file>default.html</welcome-file>
????<welcome-file>default.htm</welcome-file>
????<welcome-file>default.jsp</welcome-file>
??</welcome-file-list>
</web-app>
1 回答
已采納

堂堂堂堂糖糖糖童鞋
TA貢獻101條經驗 獲得超58個贊
我覺得是
<url-pattern>*.action</url-pattern>
的問題,你不是有分頁吧,那樣的話url格式就變了吧,懶加載就會失效。
如果是這樣的話,改為:
<url-pattern>/*</url-pattern>
即可。
添加回答
舉報
0/150
提交
取消