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的更多相关文章

  1. org.springframework.web.struts.DelegatingActionProxy

    之前也不知道用的是哪个版本的spring jar 包,后来换了之后发现问题出来了, 00:08:00,364 ERROR RequestProcessor:296 - No action instan ...

  2. Tomcat启动报错org.springframework.web.context.ContextLoaderListener类配置错误——SHH框架

    SHH框架工程,Tomcat启动报错org.springframework.web.context.ContextLoaderListener类配置错误 1.查看配置文件web.xml中是否配置.or ...

  3. maven 项目启动tomcat报错 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    maven项目启动tomcat报错: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderLi ...

  4. 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 ...

  5. java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    参考: http://www.cnblogs.com/sunxucool/archive/2013/06/07/3124380.html   ---------------------------&g ...

  6. 真正解决问题:maven eclipse tomcat java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    在使用eclipse进行整合springmvc时经常会碰到这样的异常: java.lang.ClassNotFoundException:org.springframework.web.context ...

  7. 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener

    严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderLis ...

  8. springmvc项目中java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 严重: Error co ...

  9. 错误:找不到类org.springframework.web.context.ContextLoaderListener

    严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderLis ...

随机推荐

  1. 【Kruscal最小生成树】D. Jungle Roads

    https://www.bnuoj.com/v3/contest_show.php?cid=9154#problem/D [Accepted] #include<iostream> #in ...

  2. hdu 4422

    #include<stdio.h> #include<string.h> #define inf  0x7fffffff int main() {     int i,j,k, ...

  3. github新建本地仓库,再同步远程仓库基本用法

    github新建本地仓库,再同步远程仓库基本用法 1 mkdir gitRepo 2 cd gitRepo 3 git init  #初始化本地仓库 4 git add xxx  #添加要push到远 ...

  4. 积累js中的一些问题及解决方案

    一.取字符串的第i位不兼容的问题 1.问题:对于字符串str来说,要获取第i位,常见的是str[i],但是在低版本的浏览器中不兼容,例如ie7. 2.解决:使用str.charAt(i); 二.使用定 ...

  5. 关于HTML文件、JS文件、CSS文件

    把JS和CSS脚本写在html里和写在独立文件里有什么区别? 1. 都写在html里是性能最优的方案. 2. 都写在html里是可维护性最差的方案. 3. 分开写在js.css.html是可维护性最有 ...

  6. Minimum Spanning Tree.prim/kruskal(并查集)

    开始了最小生成树,以简单应用为例hoj1323,1232(求连通分支数,直接并查集即可) prim(n*n) 一般用于稠密图,而Kruskal(m*log(m))用于系稀疏图 #include< ...

  7. Visual Studio 2017 RC的坑

    ASP.NET Core Project add Docker Project Support的问题 执行上面操作以后,如果本机没有装好docker,就会一直报错,无法build通过,无论你在Proj ...

  8. Prime Ring Problem---hdu1016(dfs)

    http://acm.hdu.edu.cn/showproblem.php?pid=1016 这就是一道简单的dfs  但是是我自己想起来的   必须要记录一下 #include<stdio.h ...

  9. Flatten Binary Tree to Linked List (DFS)

    Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ 3 4 6 T ...

  10. POJ 1511 【heap+dij】

    题意: t组样例. 每组有n个节点,有m条单向边. 有m组输入,每组a b c 表示从a到b的单向边的权值是c. 求解,从编号为1的节点出发,有n-1个人,要求他们分别到达编号从2到n的节点再返回,所 ...