`
tedeyang
  • 浏览: 318506 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

spring的ContextLoaderListener与DispatcherServlet在WebApplicationContext上的细微区别

阅读更多

我们知道spring在web.xml中可以有三种方式来配置其xml路径:
org.springframework.web.servlet.DispatcherServlet
org.springframework.web.context.ContextLoaderListener
org.springframework.web.context.ContextLoaderServlet
当使用第一种方式配置时,spring载入的WebApplicationContext是隶属于此Servlet的(所以spring可以配置多个分别拥有各自环境的DispatcherServlet),因此其他servlet无法获取到该Context。这一现象在buffalo配置时曾经出现(无法找到服务bean)。分析了buffalo和spring的源码后,将xml在ContextLoaderListener配置才得以解决。

分享到:
评论

相关推荐

    DispatcherServlet 和 ContextLoaderListener 区别

    NULL 博文链接:https://angie.iteye.com/blog/2334955

    Spring的监听器ContextLoaderListener的作用

    Spring的监听器ContextLoaderListener的作用

    java解决org.springframework.web.context.ContextLoaderListener

    java解决org.springframework.web.context.ContextLoaderListener

    Web项目中使用Spring, 使用 Spring 的器监听器 ContextLoaderListener.docx

    一、Web项目中使用Spring ...在 Web 项目中使用 Spring 框架,首先要解决在 web 层(这里指 Servlet)中获取到 Spring容器的问题。只要在 web 层获取到了 Spring 容器,便可从容器中获取到 Service 对象

    spring-web-2.5.jar

    org.springframework.web.context.ContextLoaderListener.class org.springframework.web.context.ContextLoaderServlet.class org.springframework.web.context.ServletConfigAware.class org.springframework.web....

    spring源代码解析

    可以通过使用Spring代码声明式的指定在web应用程序启动时载入应用程序上下文(WebApplicationContext),Spring的ContextLoader是提供这样性能的类,我们可以使用 ContextLoaderServlet或者ContextLoaderListener的...

    Spring MVC 入门实例

    如果你手上有一本《Spring in Action》, 那么你最好从第三部分"Spring 在 Web 层的应用--建立 Web 层"开始看, 否则那将是一场恶梦! 首先, 我需要在你心里建立起 Spring MVC 的基本概念. 基于 Spring 的 Web 应用...

    web.xml中ContextLoaderListener的运行过程解析

    web.xml中ContextLoaderListener的运行

    springweb3.0MVC注解(附实例)

    org.springframework.web.context.ContextLoaderListener </listener> <!-- Spring MVC 的Servlet,它将加载WEB-INF/annomvc-servlet.xml 的 配置文件, 以启动Spring MVC模块--> <servlet-name>annomvc ...

    spring和hibernate整合

    org.springframework.web.context.ContextLoaderListener <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener>

    Spring-5.1.5源码

    Spring framework 5.1.5源码 Main: spring-web/org.springframework.web.context.ContextLoaderListener

    简单spring MVC 配置

    <listener-class>org.springframework.web.context.ContextLoaderListener <servlet-name>test <servlet-class>org.springframework.web.servlet.DispatcherServlet <load-on-startup>1 <servlet-name>...

    spring-simple-web:使用 Spring Framework 的简单 Web (WAR) 项目

    这个简单的例子演示了在 web 应用程序中使用的 Spring 容器,即org.springframework.web.context.WebApplicationContext Web 应用程序使用 Spring Web 侦听器初始化,例如web.xml org.springframework.web.context...

    整合struts2和spring源代码(可以直接在tomcat中运行)

    Struts2与Spring的集成要用到Spring插件包struts2-spring-plugin-x-x-x.jar,这个包是同Struts2一起发布的。Spring插件是通过覆盖(override)Struts2的ObjectFactory来增强核心框架对象的创建。当创建一个对象的...

    struts2-spring-plugin-2.1.2.jar

    struts2与spring的整合。导入struts2-spring-plugin包,在web.xml中设置spring的监听器, spring监听器对应的API类为:org.springframework.web.context.ContextLoaderListener。 struts2-spring-plugin包为我们将...

    Spring MVC 框架应用实例

    org.springframework.web.context.ContextLoaderListener <filter-name>encodingFilter org.springframework.web.filter.CharacterEncodingFilter <param-name>encoding ...

    spring_MVC源码

    本文主要介绍使用注解方式配置的spring mvc,之前写的spring3.0 mvc和rest小例子没有介绍到数据层的内容,现在这一篇补上。下面开始贴代码。 文中用的框架版本:spring 3,hibernate 3,没有的,自己上网下。 先说...

    springmybatis

    mybatis实战教程mybatis in action之五与spring3集成附源码 mybatis实战教程mybatis in action之六与Spring MVC 的集成 mybatis实战教程mybatis in action之七实现mybatis分页源码下载 mybatis实战教程mybatis in ...

    SPRING API 2.0.CHM

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

    基于java的企业级应用开发:Spring的核心容器.ppt

    spring/applicationContext.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> ApplicationContext * * * *...

Global site tag (gtag.js) - Google Analytics