SSH整合问题:Write operations are not allowed in read-only mode

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gsycwh/article/details/52824222

Write operations are not allowed in read-only mode

报错信息:

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

在只读模式中,写操作是不被允许的,所以在执行操作的时候会报错,解决的方法是将你的Session改成FlushMode.COMMIT/AUTO或者清除事务定义中的readOnly标记。

在你的web.xml文件中添加以下的配置,修改OpenSessionInview过滤器:

    <!-- OpenSessionInView过滤器 -->
    <filter>
        <filter-name>OpenSessionInViewFilter</filter-name>
        <filter-class>
            org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
        <init-param>
            <param-name>sessionFactoryBeanName</param-name>
            <param-value>sessionFactory</param-value>
        </init-param>
        <init-param>
            <param-name>singleSession</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>flushMode</param-name>
            <param-value>AUTO</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>OpenSessionInViewFilter</filter-name>
        <url-pattern>*.do</url-pattern>
    </filter-mapping>

重新发布项目,启动tomcat即可。



发表人:梦想的边缘

猜你喜欢

转载自blog.csdn.net/gsycwh/article/details/52824222