Spring DispatcherServlet Multiple Instances

Ok Spring Guru ... break it for me. While reading the Spring MVC documentation, I look through this instruction:

"... Spring's ApplicationContext instances may be limited. In a Web MVC environment, each DispatcherServlet has its own WebApplicationContext, which inherits all the beans already defined in the root WebApplicationContext. These inherited beans can be overridden in a servlet-specific area, and the new beans for a specific area can be defined locally for a given servlet instance. "

Spring Document Reference

I have a few questions based on this:

  • The statement implies that there may be more than one instance of DispatcherServlet. This is absolutely NOT true because there is only one servlet instance in the web application (and ideally)?
  • What exactly does “servlet-dependent scope” mean in the context of the above statement?
+5
source share
1 answer

This is not completely NOT true.

It means “sometimes true,” which I don’t think you meant.

in a web application, only one servlet instance can (and should ideally) exist

This is not entirely incorrect - simply incorrect. You are mixing <servlet>the deployment descriptor element ( web.xml) with a class that implements this servlet.

, , , . <servlet>, .

", ",

(, , ): , , URL- , . - -. beans.

+2

All Articles