Spring MVC Explanation

Source: Internet
Author: User

Springmvc is in Spring on the basis of the architecture. the big thing about Spring is that the bean definition in XML is transformed into a container Beandefinition, and then instantiate it for use by the user.


of our Web of the program Spring Container is : Org.springframework.web.context.support.XmlWebApplicationContext, It is configured in contextloader.properties the. Created when the program initiates initialization of Contextloaderlistener and is saved in ServletContext . Container-loaded XML path is configured in Web. contextconfiglocation Field.

The first one . : Springmvc Where is the configuration file and what is the container?

Springmvc will first see if it already exists Spring container, if present, will be Spring Container as the parent container, generating its own Xmlwebapplicationcontext . If not, it is created directly. Createdat the time ofDispatcherservlet initialization, completed by Init->initservletbean . That is, if you configure multiple dispatcherservlet , they are isolated from each other. :


container to find the XML file path is Servlet of the servlet-name+ "servlet". Xml.

second question: Springmvc How the service is provided.

The approximate code is placed in Doservice , the process code is very clear and can be represented by the following diagram (using take doctrine, which others draw is really good):


Six steps:

1. get Handler ( The Controller we wrote ) and its interceptor according to the configuration.

2. execution of interceptor 's prehandle

3. adapt the Handler and perform

4. execution of interceptor 's posthandle

5. Find the View

6. Enter View to populate the model data and show

The third problem is that our developer platform uses Velocity, How is it integrated?

As you can see from the service flow above, the fifth step is to get View.

by configuration we know that view Org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver , Then the corresponding view velocityview velocity velocityview

then the sixth step is to populate the data, and it will create our Velocity of the Velocitycontext , and then create them based on the template address Template , then give Velocity it.

Of course, this step is a bit of a pit I am still groping.


Spring MVC Explanation

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.