spring+struts+hibernate OpenSessionInView 配置学习
在web.xml中使用OpenSessionInView不能配置:
xml 代码
- <servlet>
- <servlet-name>contextservlet-name>
- <servlet-class>
- org.springframework.web.context.ContextLoaderServlet
- servlet-class>
- <load-on-startup>1load-on-startup>
- servlet>
需要配置 org.springframework.web.context.ContextLoaderListener:
xml 代码
- <listener>
- <listener-class>
- org.springframework.web.context.ContextLoaderListener
- listener-class>
- listener>
并且需要配置 org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
xml 代码
- <filter>
- <filter-name>OpenSessionInViewfilter-name>
- <filter-class>
- org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
- filter-class>
- <init-param>
- <param-name>singleSessionparam-name>
- <param-value>trueparam-value>
- init-param>
- filter>
格外注意:
在配置struts-config.xml文件时,为了整合spring ,需要配置plugin:
xml 代码
- <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
- <set-property property="contextConfigLocation"
- value="/WEB-INF/classes/action- servlet.xml"/>
- plug-in>
具体见:http://www.iteye.com/topic/15057
但是,指定contextConfigLocation属性时, 只需要将配置strutsAction部分的spring配置文件引入,不能将配置数据源和事务管理的配置文件引入,否则OpenSessionInView将失效。
分享到:
相关推荐
2.通过spring注入dao到 action 3.通过 open session in view filter 支持 延迟加载 4.在页面上通过 jstl 很优雅的获取数据 5.通过 spring aop(aspectJ) 声明事务 6.通过formular 映射参数表,指定两个死的变量
最新版SSH项目整合 实现了OpenSessionInView。 hibernate5.2.3+struts2.5.2+spring4.3.3
介绍Spring+hibernate opensessioninview问题
spring2.5学习PPT 传智博客 01_全面阐释Spring及其各项功能 02_搭建与测试Spring的开发环境 03_编码剖析Spring管理Bean的原理 04_Spring的三种实例化Bean的方式 05_配置Spring管理的bean的作用域 06_Spring...
Spring提供的CharacterEncoding和OpenSessionInView功能
SSH项目整合示例【OpenSessionInView】所用到的jar包 包含Struts + Hibernate + Spring所有jar及其依赖的jar
NULL 博文链接:https://8366.iteye.com/blog/472141
3,在web.xml中配置 spring 的 OpenSessionInView 过滤器(解决抛LazyInitializationException的问题) 1,配置 <!-- 配置 spring 的 OpenSessionInView 过滤器 --> <filter-name>OpenSessionInView ...
和Spring中OpenSessionInView由于org.springframework.web.struts.ContextLoaderPlugIn中保存同一个对象的名不同导致openSessionInView失效 稍微修改后在struts-config.xml中使用MyContextLoaderPlugIn.jar包中...
目录 1.1 Spring 框架学习路线:...........................................................................................................................4 1.2 Spring 框架的概述:...........................
OpenSessionInView项目整合jar包
在没有使用Spring提供的Open Session In View情况下,因需要在service(or Dao)层里把session关闭,所以lazy loading 为true的话,要在应用层内把关系集合都初始化,如 company.getEmployees(),否则Hibernate抛...
NULL 博文链接:https://likenice.iteye.com/blog/290162
NULL 博文链接:https://yanzhenwei.iteye.com/blog/1701164
SSH项目整合示例【OpenSessionInView】源码
使用 AOC 拦截器而不是过滤器进行 OpenSessionInView 处理 列出一个国家的城市和添加城市的可能性(bean 验证和自动检索 lat 和 lng 坐标) 安全 安全的 REST Web 服务 使用 CSRF 令牌 角度父状态的问题 有用的链接 ...