Difference between Applicationcontext.xml and SPRI

Source: Internet
Author: User

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

the  applicationcontext.xml  defines The beans for the "root webapp context", i.e. the context Asso Ciated with the WebApp.

the  spring-servlet.xml   (or whatever else call it) defines the beans for one servlet ' s app cont Ext. There can many of these in a webapp, one per Spring servlet (e.g.  spring1-servlet.xml  for Servle t  spring1 ,   spring2-servlet.xml  for servlet  spring2 ).

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

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

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



Question:

Why would multiple spring servlets?


It's sometimes useful to separate parts of your application, could otherwise conflict in the same context. As an example your may has ReST services and standard views, which you and different view resolvers or security concer NS for the services as-to-the views.

Difference between Applicationcontext.xml and SPRI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.