多个应用程序上下文,多个调度程序servlet? [英] Multiple application context, multiple dispatcher servlets?

查看:80
本文介绍了多个应用程序上下文,多个调度程序servlet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到现在,我以前一直认为Web应用程序只能有一个我们在web.xml

Until now I used to think that a web-application can have only one dispatcher-servlet which we define in web.xml

  • 我是这样认为的吗?
  • 我可以在一个Web应用程序中拥有多个调度程序servlet吗?如果是,怎么办?
  • 在什么情况下我们可能需要此服务?
  • 整个Web应用程序中只能有一个应用程序上下文吗?
  • 我们如何定义多个应用程序上下文?
  • 在非Spring应用程序中可以存在dispatcher-servlet吗?
  • Am I right in thinking so?
  • Can i have multiple dispatcher servlets in a single web application? If yes, How?
  • What is a situation we might need this in?
  • Can there only be a single application context in the entire web application?
  • How can we define multiple application contexts?
  • Can a dispatcher-servlet exist in a non-spring application?

推荐答案

在一个Web应用程序中可以有多个调度程序servlet吗?

Can you have multiple dispatcher servlets in a single web application ?

当然,请引用官方文档(实际上也有粗体!)

Of course, quoting the official documentation (bold is actually there as well!)

Web应用程序可以定义任意数量的DispatcherServlets .每个servlet将在其自己的名称空间中运行,并使用映射,处理程序等加载其自己的应用程序上下文.只有ContextLoaderListener加载的根应用程序上下文(如果有)将被共享.

A web application can define any number of DispatcherServlets. Each servlet will operate in its own namespace, loading its own application context with mappings, handlers, etc. Only the root application context as loaded by ContextLoaderListener, if any, will be shared.


如何?

只需使用org.springframework.web.servlet.DispatcherServlet类声明几个具有不同名称的servlet.还要确保yourServletName-servlet.xml文件可用.

Just declare several servlets with different names but using org.springframework.web.servlet.DispatcherServlet class. Also make sure yourServletName-servlet.xml file is available.

在什么情况下我们可能需要这个?

What is a situation we might need this in ?

DispatcherServlet非常灵活.不仅Spring MVC会使用它,而且Spring WS也会使用它,Spring对

DispatcherServlet is very flexible. Not only Spring MVC uses it, but also Spring WS, Spring support for hessian, etc.

此外,整个Web应用程序中只能有一个应用程序上下文吗?

Also, can there only be a single application context in the entire web application ?

在引用的文档中也已经回答:每个DispatcherServlet一个应用程序上下文+一个主要的Web应用程序上下文.

Answered already, also in the quoted documentation: one application context per DispatcherServlet + one main web application context.

我们如何定义多个应用程序上下文?

How can we define multiple application contexts ?

请参见上文,只需创建多个DispatcherServlet.

See above, just create multiple DispatcherServlets.

在非Spring应用程序中可以存在调度程序servlet吗?

Can a dispatcher servlet exist in a non-spring application ?

DispatcherServlet本身就是一个Spring上下文(Spring应用程序),因此:否.一方面,DispatcherServlet可以在不具有父(主)应用程序上下文的应用程序中声明,因此:是.

DispatcherServlet is a Spring context (Spring application) on its own, thus: no. On the hand DispatcherServlet can be declared in an application not having parent (main) application context, thus: yes.

这篇关于多个应用程序上下文,多个调度程序servlet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆