SSH整合报错:Write operations are not allowed in read-only mode (FlushMode.MANUAL)

初学SSH,开发示例发现报错:Write operations are not allowed in read-only mode (FlushMode.MANUAL),看报错信息大概知道是HibernateTemplate.save保存数据时无写的权限,在网上查了很多,试了几个方法都得不通,最终发现,需要同时修改ApplicationContext.xml和web.xml两个文件,问题解决。

web.xml增加以下配置:


	         OpenSessionInViewFilter
	         org.springframework.orm.hibernate5.support.OpenSessionInViewFilter
	         
	                   sessionFactoryBeanName
	                   sessionFactory
	         
	         
	                   singleSession
	                   true
	         
	         
	                   flushMode
	                   AUTO 
	         
	
	
	         OpenSessionInViewFilter
	         /*
	

ApplicationContext.xml增加以下配置:


	
		
	
	
	
		
	
	
	
		
			
		
		
			
				PROPAGATION_REQUIRED
				PROPAGATION_REQUIRED
				PROPAGATION_REQUIRED
				PROPAGATION_REQUIRED
				PROPAGATION_REQUIRED
				PROPAGATION_REQUIRED,readOnly
				PROPAGATION_REQUIRED,readOnly
				PROPAGATION_REQUIRED
			
		
	
	
	
		
			
				txInterceptor
			
		
		
			
				*Dao
				*Service
			
		
	

你可能感兴趣的:(SSH)