Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)..

在保存时候总是弹出对话框:  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.
  大概意思翻译了下是:只读模式下(FlushMode.NEVER/MANUAL)写操作不被允许:把你的Session改成FlushMode.COMMIT/AUTO或者清除事务定义中的readOnly标记。


  解决方案:
     在 web.xml配置里添加
<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>


你可能感兴趣的:(Web,xml,orm)