亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

OpenSessionInViewFilter處理懶加載只能生效一次,刷新一次后又沒了

OpenSessionInViewFilter處理懶加載只能生效一次,刷新一次后又沒了

fenkapian 2016-10-17 23:16:38
在頁面上顯示員工信息,其中員工所屬部門需要關閉懶加載才能顯示。而用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>

即可。

查看完整回答
反對 回復 2016-10-18
  • 1 回答
  • 1 關注
  • 1837 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號