java – 为什么Spring MVC需要至少两个上下文?

栏目: Java · 发布时间: 7年前

内容简介:在Spring MVC中,有两个上下文.一个是由ContextLoaderListener引导的应用程序上下文或全局上下文.它需要在contextConfigLocation参数中提到的所有配置文件.现在,如果您也使用Spring MVC,那么需要调度程序servlet,它启动另一个也称为Web应用程序容器的容器.该容器将全局容器作为父项.当将struts1与spring集成时,只有一个上下文.为什么春季mvc需要两个?当使用spring mvc时,是否只能使用一个上下文?

在Spring MVC中,有两个上下文.一个是由ContextLoaderListener引导的应用程序上下文或全局上下文.它需要在contextConfigLocation参数中提到的所有配置文件.

现在,如果您也使用Spring MVC,那么需要调度程序servlet,它启动另一个也称为Web应用程序容器的容器.该容器将全局容器作为父项.

当将struts1与spring集成时,只有一个上下文.为什么春季mvc需要两个?当使用spring mvc时,是否只能使用一个上下文?

谢谢!

想象一下,你有两个独立的调度员,每个调度器都有不同的目的,每个都有自己的依赖关系.您将使用单独的上下文独立配置它们.

如果有任何共享配置,这可以在’全局’上下文中.

我不认为只有一个上下文可以使用DispatcherServlet,因为它创建自己的上下文并将其链接到父上下文(通过FrameworkServlet超类).

FrameworkServlet.createWebApplicationContext

http://stackoverflow.com/questions/18682486/why-does-spring-mvc-need-at-least-two-contexts


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Agile Web Application Development with Yii 1.1 and PHP5

Agile Web Application Development with Yii 1.1 and PHP5

Jeffrey Winesett / Packt Publishing / 2010-08-27

In order to understand the framework in the context of a real-world application, we need to build something that will more closely resemble the types of applications web developers actually have to bu......一起来看看 《Agile Web Application Development with Yii 1.1 and PHP5》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具