概述
SSH框架版本struts2.3+hibernate4.3+spring4.0
Struts has detected an unhandled exception:
Write operations are not allowedin read-only mode (FlushMode.MANUAL): Turn your Session intoFlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
解决方法:
<1>在application-context.xml中添加事务处理
<!-- 配置事务管理器-->
<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="add*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="managersMethod"
expression="execution( *com.love.lifang.struts2spring.dao.impl.*Impl.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="managersMethod"/>
</aop:config>
<2>如果还出现异常严重:
Exceptionsending context destroyed event to listener instance of classorg.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initializedor already closed - call 'refresh' before accessing beans via theApplicationContext
Caused by: java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
这是由于缺少必要的jar包引起的,还需要添加
aspcetjrt.jar、apcetjweaver.jar、com.springsource.org.aopalliance-1.0.0.jar这三个包
最后
以上就是自觉月亮为你收集整理的SSH:Struts has detected an unhandled exceptionStruts has detected an unhandled exception: Write operations are not allowedin read-only mode (FlushMode.MANUAL): Turn your Session intoFlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction d的全部内容,希望文章能够帮你解决SSH:Struts has detected an unhandled exceptionStruts has detected an unhandled exception: Write operations are not allowedin read-only mode (FlushMode.MANUAL): Turn your Session intoFlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction d所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复