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 3047 Zjnu Stadium
http://acm.hdu.edu.cn/showproblem.php?pid=3047 [题意] http://blog.csdn.net/hj1107402232/article/detail ...
- bzoj1004 [HNOI2008]Cards 置换群+背包
[bzoj1004][HNOI2008]Cards 2014年5月26日5,3502 Description 小春现在很清闲,面对书桌上的N张牌,他决定给每张染色,目前小春只有3种颜色:红色,蓝色,绿 ...
- react.js 高阶组件----很简单的实例理解高阶组件思想
调试代码之前,我设置了两个缓存 分别是username和content 在控制台console设置两个缓存代码 localStorage.setItem('username','老王')localSt ...
- 解决Genymotion不能安装软件的问题
解决Genymotion不能安装软件的问题 官方取消了with google apps字样的rom,导致安装app不兼容的解决 有些童鞋在兴奋的打开Genymotion模拟器后可能会发现无法安装下载下 ...
- 制作U盘Puppy-Live启动盘
制作U盘Puppy-Live启动盘 准备工具和材料:Puppy的ISO镜像文件.UltraISO工具.100M以上的U盘 开始: 1.用Ultraiso打开下载的镜像文件,然后选择菜单栏里面的&quo ...
- Java并发包——Atomic操作
Java并发包——Atomic操作 摘要:本文主要学习了Java并发包下的atomic包中有关原子操作的一些类. 部分内容来自以下博客: https://blog.csdn.net/qq_303796 ...
- 转: 关于Linux常用的二进制文件分析方法
当你在unix下拿到一个二进制文件但不知道它是什么的时候,可以通过以下方法得到一此提示 1. 最首先应该尝试strings命令,比如拿到一个叫cr1的二进制文件,可以: $ strings cr1 | ...
- Meteor事件
使用事件是非常简单的.我们将学习如何使用tag,class 和id作为事件选择器. 让我们创建HTML模板三大要素.第一个是 p 标签,第二个是 myClass 类,最后一个是myId. meteor ...
- 247. Segment Tree Query II
最后更新 二刷 09-Jna-2017 利用线段树进行区间查找,重点还是如何判断每一层的覆盖区间,和覆盖去见与当前NODE值域的关系. public class Solution { public i ...
- Android 开源框架ViewPageIndicator 和 ViewPager 仿网易新闻clientTab标签
之前用JakeWharton的开源框架ActionBarSherlock和ViewPager实现了对网易新闻clientTab标签的功能,ActionBarSherlock是在3.0下面的机器支持Ac ...