`

org.springframework.web.struts.ContextLoaderPlugIn 和 org.springframework.web.con

 
阅读更多

转载至:http://www.blogjava.net/beijing2008/articles/317973.html

 

org.springframework.web.struts.ContextLoaderPlugIn 和 org.springframework.web.con

是视图层加载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加载方式。

分享到:
评论

相关推荐

    spring-struts.jar

    org.springframework.web.struts.ContextLoaderPlugIn.class org.springframework.web.struts.DelegatingActionProxy.class org.springframework.web.struts.DelegatingActionUtils.class org.springframework.web....

    MyContextLoaderPlugIn.jar

    和Spring中OpenSessionInView由于org.springframework.web.struts.ContextLoaderPlugIn中保存同一个对象的名不同导致openSessionInView失效 稍微修改后在struts-config.xml中使用MyContextLoaderPlugIn.jar包中...

    Spring API

    13. Web MVC framework Web框架 13.1. 概述 13.1.1. 与其他MVC实现框架的集成 13.1.2. Spring Web MVC框架的特点 13.2. DispatcherServlet 13.3. 控制器 13.3.1. AbstractController 和 WebContentGenerator ...

    spring chm文档

    Spring Framework 开发参考手册 Rod Johnson Juergen Hoeller Alef Arendsen Colin Sampaleanu Rob Harrop Thomas Risberg Darren Davison Dmitriy Kopylenko Mark Pollack Thierry Templier Erwin ...

    Spring 2.0 开发参考手册

    6.1.2. Spring AOP的功能和目标 6.1.3. Spring的AOP代理 6.2. @AspectJ支持 6.2.1. 启用@AspectJ支持 6.2.2. 声明一个切面 6.2.3. 声明一个切入点(pointcut) 6.2.4. 声明通知 6.2.5. 引入(Introductions)...

    Spring中文帮助文档

    13. Web MVC framework Web框架 13.1. 概述 13.1.1. 与其他MVC实现框架的集成 13.1.2. Spring Web MVC框架的特点 13.2. DispatcherServlet 13.3. 控制器 13.3.1. AbstractController 和 WebContentGenerator ...

    Spring-Reference_zh_CN(Spring中文参考手册)

    6.1.2. Spring AOP的功能和目标 6.1.3. Spring的AOP代理 6.2. @AspectJ支持 6.2.1. 启用@AspectJ支持 6.2.2. 声明一个切面 6.2.3. 声明一个切入点(pointcut) 6.2.3.1. 切入点指定者的支持 6.2.3.2. 合并切入点...

    SPRING API 2.0.CHM

    ContextLoaderPlugIn ContextLoaderServlet ContextRefreshedEvent ContextSingletonBeanFactoryLocator ControlFlow ControlFlowFactory ControlFlowFactory.Jdk13ControlFlow ControlFlowFactory.Jdk14...

    为何不使用ContextLoaderPlugIn也可以正常使用DelegatingRequestProcessor和DelegatingActionProxy整

    NULL 博文链接:https://qq421606162.iteye.com/blog/2000148

    构建支持Ajax的轻量级J2EE框架

    本文是在Spring+Struts构建的轻量级框架基础上,通过让Buffalo用Spring放在ServletContext里面的 WebApplicationContext(ContextLoaderPlugIn实现把WebApplicationContext的实例放在了 ServletContext中来实现了一...

Global site tag (gtag.js) - Google Analytics