<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 6  文章 - 129  trackbacks - 0
    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿(14)

    隨筆檔案(6)

    文章分類(467)

    文章檔案(423)

    相冊

    收藏夾(18)

    JAVA

    搜索

    •  

    積分與排名

    • 積分 - 828791
    • 排名 - 49

    最新評論

    閱讀排行榜

    評論排行榜

    Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

    今天在做事務測試的時候,控制臺輸出了以上的錯誤信息,在網(wǎng)上找了一下,原來是我在web.xml
    文件中設置了OpenSessionInView .  將設置去掉就可以了.
    <!-- OpenSessionInView -->
      <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>
    或者加上事務設置

    <?xml version="1.0" encoding="UTF-8"?>
    <beans
     xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
     xsi:schemaLocation="
     http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
     http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"
     >
     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory" ref="sessionFactory"></property>
     </bean>
     
     <tx:advice id="txAdvice" transaction-manager="transactionManager">
      <tx:attributes>
       <tx:method name="create*" propagation="REQUIRED"/>
       <tx:method name="update*" propagation="REQUIRED"/>
       <tx:method name="delete*" propagation="REQUIRED"/>
       <tx:method name="find*" propagation="REQUIRED" read-only="true"/>
       <tx:method name="*" read-only="true"/>
      </tx:attributes>
     </tx:advice>
     
     <aop:config>
      <aop:pointcut id="daoOperation" expression="execution(* dgut.ke.dao.*.*(..))"/>
      <aop:advisor advice-ref="txAdvice" pointcut-ref="daoOperation"/>
     </aop:config>
     
    </beans>

    網(wǎng)上又說
    盡管Open Session In View看起來還不錯,其實副作用不少。看回上面OpenSessionInViewFilter的doFilterInternal方法代碼,這個方法實際上是被父類的doFilter調用的,因此,我們可以大約了解的OpenSessionInViewFilter調用流程: request(請求)->open session并開始transaction->controller->View(Jsp)->結束transaction并close session.

         一切看起來很正確,尤其是在本地開發(fā)測試的時候沒出現(xiàn)問題,但試想下如果流程中的某一步被阻塞的話,那在這期間connection就一直被占用而不釋放。最有可能被阻塞的就是在寫Jsp這步,一方面可能是頁面內容大,response.write的時間長,另一方面可能是網(wǎng)速慢,服務器與用戶間傳輸時間久。當大量這樣的情況出現(xiàn)時,就有連接池連接不足,造成頁面假死現(xiàn)象。

    Open Session In View是個雙刃劍,放在公網(wǎng)上內容多流量大的網(wǎng)站請慎用。




    posted on 2007-11-16 16:51 Ke 閱讀(1956) 評論(0)  編輯  收藏 所屬分類: exception
    主站蜘蛛池模板: 免费无码又爽又刺激毛片| 亚洲av永久无码精品漫画| 18观看免费永久视频| 一本大道一卡二大卡三卡免费| 亚洲性无码av在线| 亚洲AV无码第一区二区三区| 亚洲人成电影网站国产精品| 在线观看亚洲免费| 精品国产sm捆绑最大网免费站| 精品熟女少妇aⅴ免费久久| 亚洲日韩精品无码专区加勒比☆| 亚洲Av永久无码精品三区在线| 中文字幕中韩乱码亚洲大片 | 亚洲欧洲视频在线观看| 国产亚洲精品精华液| 亚洲天堂中文字幕在线| 四虎亚洲国产成人久久精品| 最近免费字幕中文大全| 免费国产在线精品一区| 久久亚洲色WWW成人欧美| 在线亚洲高清揄拍自拍一品区| 1区1区3区4区产品亚洲| 亚洲日本一区二区三区| 亚洲高清在线视频| 久久精品国产99精品国产亚洲性色| 久久青青草原亚洲av无码| 亚洲国产一区视频| 亚洲人成无码网WWW| 亚洲精品天堂成人片?V在线播放| 国产免费无遮挡精品视频| 最好免费观看韩国+日本| 成人免费一区二区三区在线观看| 免费A级毛片无码免费视| 歪歪漫画在线观看官网免费阅读| 国产福利在线观看免费第一福利| 黄瓜视频影院在线观看免费| 成人无码区免费A片视频WWW| 美女网站免费福利视频| 在线视频免费观看www动漫| 国产男女性潮高清免费网站 | 亚洲国产精品无码中文lv|