Spring+hibernate懒加载问题

养生程序猿 发布于 2014/03/01 14:36
阅读 1K+
收藏 0
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
	<!-- 指定spring容器配置文件所在位置 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:config/applicationContext-*.xml</param-value>
	</context-param>

	<!-- 为了启动服务器时,创建spring容器对象 -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!--
		<listener>
		<listener-class>barcode.ScanBarcodeListener</listener-class>
		</listener>
	-->
	<filter>
		<filter-name>struts2</filter-name>
		<filter-class>
			org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>*.action</url-pattern>
	</filter-mapping>
	<filter>
		<filter-name>openSessionInView</filter-name>
		<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>openSessionInView</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>

	<!--
		<context-param> <param-name>log4jConfigLocation</param-name>
		<param-value>/WEB-INF/classes/log4j.properties</param-value>
		</context-param>
	
	<servlet>
		<servlet-name>proxool</servlet-name>
		<servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>proxool</servlet-name>
		<url-pattern>/proxool</url-pattern>
	</servlet-mapping> -->
</web-app>

为什么我的openSessionInView没有用打不开session


加载中
0
Ken5233
Ken5233
请试着将opensessionfilterview的过滤器置于第一
养生程序猿
养生程序猿
哥们。之前我也放在前面了,但是不行,今天我就又放了一次居然OK了,好像说一句,真tm的奇葩
0
Ken5233
Ken5233
filter 拦截来自 request forward 所有人请求 包括jsp
0
weir2008
weir2008
你用的是hibernate4吧?
养生程序猿
养生程序猿
是3
0
养生程序猿
养生程序猿

引用来自“helloming”的答案

请试着将opensessionfilterview的过滤器置于第一
谢谢
0
养生程序猿
养生程序猿

引用来自“helloming”的答案

请试着将opensessionfilterview的过滤器置于第一
哥们,我保存数据有报错了org.springframework.dao.InvalidDataAccessApiUsageException: 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.
Ken5233
Ken5233
自己查百度吧,这个很简单的。貌似只需要设置flush-mode解决
返回顶部
顶部