接上贴:http://topic.csdn.net/u/20090719/19/7e932bea-1104-48db-b447-9a697dcdf522.html 在网上找了很多关于配置OpenSessionInViewFilter 的文章,貌似只要在web.xml中加: <filter>
<filter-name>OpenSessionInViewFilter </filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class> <init-param>
<param-name>singleSession </param-name>
<param-value>true </param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter </filter-name>
<url-pattern>*.do </url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation </param-name>
<param-value>/WEB-INF/applicationContext*.xml </param-value>
</context-param> 就可以了,但为什么还是org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role这个呢? 请高手指教:配置OpenSessionInViewFilter,除了设置web.xml外,还要下载其他包或者加其他代码吗?
已经有spring.jar 求详细配置方法和使用代码,这个问题困扰我好几天了,类似的问题也问了好几个,都是一两句话解答,还是没有头绪,请告诉我具体怎么做,不要一两句话太抽象,谢谢:)
<filter-name>OpenSessionInViewFilter </filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class> <init-param>
<param-name>singleSession </param-name>
<param-value>true </param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter </filter-name>
<url-pattern>*.do </url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation </param-name>
<param-value>/WEB-INF/applicationContext*.xml </param-value>
</context-param> 就可以了,但为什么还是org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role这个呢? 请高手指教:配置OpenSessionInViewFilter,除了设置web.xml外,还要下载其他包或者加其他代码吗?
已经有spring.jar 求详细配置方法和使用代码,这个问题困扰我好几天了,类似的问题也问了好几个,都是一两句话解答,还是没有头绪,请告诉我具体怎么做,不要一两句话太抽象,谢谢:)
解决方案 »
- 如何区分window.onunload()事件
- Oracle to_date函数的问题
- 请教基于java系统的汉化方法
- 如何实现一个字符串的前后顺序反转?
- [求助]小弟遇到困难了,高手们,帮帮忙啊,是关于服务器从数据库中调用数据,定时发送邮件的问题
- 大伙帮忙看看我这段代码是哪里出了问题?我就看不出错在哪里?
- <jsp:useBean id="" class="" scope="session">是什么意思
- 请问在什么地方可以下载weblogic ?
- 关于session不能超时的问题,求各位大神指点,搞不定啊!!!
- Input输入日期如何做到下面的效果
- a4j:repeat在rich:toolbar中的问题
- select值赋给input
<beans>
<bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors">
<list>
<ref bean="openSessionInViewInterceptor"/>
</list>
</property>
<property name="mappings">
......
</property>
</bean>
......
</beans>
OpenSessionInViewFilter配置:
<web-app>
......
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
</filter>
......
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
......
</web-app>