• Now all data be ready for publish, We had made our blog alive now. Haha.



  • These days CCP GFW blocked all the IPs from US and when I switch my IP in google Cloud, the disk data cannot be restore again. I have to restart my blog totally, Now the website is still building…



Difference between applicationContext.xml and spring-servlet.xml in Spring Framework- Stack Overflow

Java PingBook 2 weeks ago (10-30) 9 0

Question

Are applicationContext.xml and spring-servlet.xml related anyhow in Spring Framework?
Will the properties files declared in applicationContext.xml be available to DispatcherServlet?
On a related note, why do I need a *-servlet.xml at all? Why is applicationContext.xml alone insufficient?

Answer

Spring lets you define multiple contexts in a parent-child hierarchy.

The applicationContext.xml defines the beans for the “root webapp context”, i.e. the context associated with the webapp.

The spring-servlet.xml (or whatever else you call it) defines the beans for one servlet’s app context. There can be many of these in a webapp, one per Spring servlet (e.g. spring1-servlet.xml for servlet spring1, spring2-servlet.xml for servlet spring2).

Beans in spring-servlet.xml can reference beans in applicationContext.xml, but not vice versa.

All Spring MVC controllers must go in the spring-servlet.xml context.

In most simple cases, the applicationContext.xml context is unnecessary. It is generally used to contain beans that are shared between all servlets in a webapp. If you only have one servlet, then there’s not really much point, unless you have a specific use for it.




Copyright from PingBook Blog, If not specified, they are original. This site uses BY-NC-SAProtocol authenticated.
For reprinting, please indicate the link of the original text:Difference between applicationContext.xml and spring-servlet.xml in Spring Framework- Stack Overflow
LIKE (0)
[1725641479@qq.com]
SHARE (0)
PingBook
Author:
We create, We sharing! Tag every value data your sharing
Submit comments
Cancel comments
emoji picture bold strikethrough center italic check in

Hi,you need to provide your name and email adress!

  • Name (Required)
  • Email (Required)
  • Website