org.springframework.web.struts.ContextLoaderPlugIn 和 org.springframework.web.context.ContextLoaderListener
是视图层加载sping的两种方式。
那么这两种方式谁的优先级高,从容器加载程度上看,是org.springframework.web.context.ContextLoaderListener
那么中方式都被配置在项目中,会使用哪个一个呢?
答案是org.springframework.web.struts.ContextLoaderPlugIn
当然如果你不需要在视图层采用lazy而配置org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
那么你可以两个都配置。
但如果你需要使用,那就会。
我们知道,容器初始化Spring配置文件时,使用getServletContext().setAttribute方法key,value全局保存。
那么当你使用OpenSessionInViewFilter时,他取得的是哪个呢?
其实OpenSessionInViewFilter是sping的Filter,它采用WebApplicationContextUtils的方式获得WebApplicationContext
,但它并不能加载由struts-config.xml文件ContextLoaderPlugIn提供初始化的上下文。
如果你需要在视图层加载一对对....等关联对象。那么就会有
could not initialize proxy - the owning Session was closed
错误。
到此处我们看到,sping在应用程序和OpenSessionInViewFilter之间,加载了不同的上下文。
我们知道OpenSessionInViewFilter下无法获得ContextLoaderPlugIn加载的上下文,那我们可以推算,
应用程序应该加载了ContextLoaderPlugIn上下文,而OpenSessionInViewFilter却加载了ContextLoaderListener的上下文。
才导致视图层session有关闭的问题。
尝试解决此问题,若你配置了两个,则删除ContextLoaderPlugIn的加载方式。
若你只配置了ContextLoaderPlugIn的加载方式,则改成ContextLoaderListener加载方式。
原创文章,转载请注明出处。
http://www.blogjava.net/beijing2008/articles/317973.html
org.springframework.web.struts.ContextLoaderPlugIn 和 org.springframework.web.context.ContextLoaderListener的更多相关文章
- org.springframework.web.struts.DelegatingActionProxy
之前也不知道用的是哪个版本的spring jar 包,后来换了之后发现问题出来了, 00:08:00,364 ERROR RequestProcessor:296 - No action instan ...
- Tomcat启动报错org.springframework.web.context.ContextLoaderListener类配置错误——SHH框架
SHH框架工程,Tomcat启动报错org.springframework.web.context.ContextLoaderListener类配置错误 1.查看配置文件web.xml中是否配置.or ...
- maven 项目启动tomcat报错 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
maven项目启动tomcat报错: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderLi ...
- Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException:
严重: Exception sending context initialized event to listener instance of class org.springframework.we ...
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
参考: http://www.cnblogs.com/sunxucool/archive/2013/06/07/3124380.html ---------------------------&g ...
- 真正解决问题:maven eclipse tomcat java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
在使用eclipse进行整合springmvc时经常会碰到这样的异常: java.lang.ClassNotFoundException:org.springframework.web.context ...
- 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderLis ...
- springmvc项目中java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 严重: Error co ...
- 错误:找不到类org.springframework.web.context.ContextLoaderListener
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderLis ...
随机推荐
- 没有上司的舞会(hdu 1520)
题目描述 Description Ural大学有N个职员,编号为1~N.他们有从属关系,也就是说他们的关系就像一棵以校长为根的树,父结点就是子结点的直接上司.每个职员有一个快乐指数.现在有个周年庆宴会 ...
- 单源最短路径 Bellman_ford 和 dijkstra
首先两个算法都是常用于 求单源最短路径 关键部分就在于松弛操作 实际上就是dp的感觉 if (dist[e.to] > dist[v] + e.cost) { dist[e.to] = dist ...
- BZOJ2196: [Usaco2011 Mar]Brownie Slicing
n<=500 * m<=500的方阵,先沿横坐标切A-1刀,再把每一块切B-1刀,得到A*B块,求这A*B块的数字之和的最小值的最大值. 最小值最大--二分,然后贪心切.每次扫一行,看这一 ...
- maven 编译出错 Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean
eclipse在使用maven的tomcat控件编译java程序时,报错 Failed to execute goal org.apache.maven.plugins:maven-clean-plu ...
- msp430项目编程24
msp430中项目---MMC接口 1.串行通信工作原理 2.串行通信协议 3.代码(显示部分) 4.代码(功能实现) 5.项目总结 msp430项目编程 msp430入门学习
- 最少拦截系统-----hdu1257(dp+最长上升子序列)
Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高 ...
- jree-创建普通折线图
对于maven工程,需要引入依赖:在pom.xml中,添加如下内容 <dependency> <groupId>jfree</groupId> <artifa ...
- Android自己定义之TextView跑马灯的监听
TextView都有跑马灯的效果,假设说让你去监听跑马灯效果的运行.我认为这个需求有点二了.可是也要实现. 思路: 1.自己定义View 继承TextView 这样的方法过于麻烦,仅仅是监听一个 ...
- iOS中3种正则表达式的使用
1.利用NSPredicate(谓词)匹配 例如匹配有效邮箱: ? 1 2 3 4 NSString *email = @“nijino_saki@163.com”: NSString *regex ...
- RGB中的颜色的设置
用来表示一个 RGB 颜色值. 语法 RGB(red, green, blue) RGB 函数的语法含有以下这些命名参数: 部分 描述 red 必要参数:Variant (Integer).数值范围从 ...