Springmvc context vs. Springcontext context

Source: Internet
Author: User

Content excerpt from: Springmvc Relationship to Spring context

Principle Difference

It is not clear that the Springmvc-servlet.xml configuration has a contextual relationship with the Spring.xml two configuration files. Finding a top article today is suddenly clear.

Specifically, the Spring.xml context and the springmvc-servlet.xml context are the parent-child container context, and they have the following relationship characteristics:

    • The context defined by Spring.xml is the parent context and cannot invoke the context of the child container, that is, the springmvc-servlet.xml cannot be called;
    • Springmvc-servlet.xml defines the sub-class to ask, you can call the parent container spring.xml context content;

Believe you see here, if you look at the Java Virtual Machine specification, it should be thought that this design is similar to ClassLoader's "Parental delegation Model".

Practical application

After knowing the principle difference, actually in the application, often has two kinds of modes:

Traditional type

The so-called traditional type, is the action, service, DAO Three layer architecture, based on the complex business of large company development model.

For this mode, the general spring context is controlled on the service, DAO two layer, and the thing integrity is also controlled at the service layer, while the Springmvc-servlet controls the action layer.

This result results in the following call relationships:

    • Action can invoke service, DAO;
    • Service, DAO cannot invoke action;
    • The AOP of the spring context container cannot be applied to the action layer, but it can be done by defining it in Springmvc-servlet.xml.
Radical type

The so-called radical type, is to speed, do not write so many classes, do not use the traditional action, service, DAO three-layer mode, direct integration, docking reverse telecommuting, such as the speed of work can be considered.

For aggressive development, it's easy to use the sub-context of Springmvc-servlet.xml to manage all the content.

Springmvc context vs. Springcontext context

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.