一、手動加載 如:
          Hibernate.initialize(obj.getUser());//加載用戶對象 



          二、使用OpenSessionInViewFilter 配置解決延遲加載 如:
          <!--OpenSessionInViewFilter 解決延遲加載問題 --> 
          <filter> 
          <filter-name>OpenSessionInViewFilter</filter-name> 
          <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter                </filter-class> 
          <!-- singleSession默認(rèn)為true,若設(shè)為false則等于沒用OpenSessionInView --> 
          <init-param> 
          <param-name>singleSession</param-name> 
          <param-value>true</param-value> 
          </init-param> 
          </filter> 
          <filter-mapping> 
          <filter-name>OpenSessionInViewFilter</filter-name> 
          <url-pattern>/*</url-pattern> 
          </filter-mapping> 


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           

          posts - 34, comments - 38, trackbacks - 0, articles - 0

          Copyright © 陳小東

          主站蜘蛛池模板: 株洲市| 九龙城区| 涟水县| 原阳县| 井冈山市| 新巴尔虎右旗| 洪江市| 满城县| 松原市| 辽源市| 阿坝县| 黔南| 通化县| 吕梁市| 龙井市| 隆回县| 镇巴县| 江孜县| 沐川县| 济阳县| 临汾市| 卓尼县| 和静县| 随州市| 长岛县| 班玛县| 东至县| 桑日县| 武隆县| 朝阳县| 环江| 阳江市| 阳曲县| 时尚| 邵武市| 株洲市| 西吉县| 偏关县| 顺昌县| 桐乡市| 蒙城县|