Spring Learning Summary (2.1)-spring MVC

Source: Internet
Author: User

IntroductionSpring MVC is the use of the MVC pattern in the UI, and of course Spring MVC is just one of them. This model is characterized by the separation of the model, the view, the controller three kinds of roles. Separate the business processing from the UI design and into the model and controller design, allowing them to decouple from each other. In this way, they can be expanded independently.
Process

    1. Client request submitted to Dispatcherservlet
    2. One or more handlermapping are queried by the Dispatcherservlet controller to locate the controller that handles the request
    3. Dispatcherservlet submits the request to the controller
    4. After the controller invokes the business logic processing, it returns Modelandview
    5. Dispatcherservlet query One or more Viewresoler view resolvers to find the Modelandview specified view
    6. The view is responsible for displaying the results to the client

the relationship between the web and spring MVC    Spring MVC are also part of the spring framework, so spring MVC is also used based on the IOC container. The spring IOC container is a standalone module that cannot be used directly in a Web container. So you need to design a process to start and initialize the IOC container. Look at the following configuration file:
<span Style= "FONT-FAMILY:FANGSONG_GB2312;FONT-SIZE:18PX;" > <listener> <listener-class>org.springframework.web.context.contextloaderlistener</                   listener-class> </listener> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init -param> <param-name>contextConfigLocation</param-name> <param-value>/        Web-inf/spring-mvc.xml,classpath:config/applicationcontext-common.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet></span> 
The two configuration items listener Configure a listener to listen for the Web container's startup and then trigger the spring IOC to load into the Web container. The servlet configuration item is configured with the main distributor of Spring MVC. Where the parameter specifies the XML file path of the configured bean. The Listener and Dispatcherservlet here provide a portal for Web context access to spring MVC.
context launches in a Web containerin fact, starting spring MVC in the web is creating a contextual relationship. The first time Dispatcherservlet intercepts an HTTP request requires spring MVC to provide it with the appropriate processing class. All well-configured classes that require Spring MVC management form a system context. In other words, the so-called context can be simply understood as a collection of beans.
for the creation of the relationship in the afternoon, the root context was created by the web context, and the remaining child context relationships were created by Contextloader. So spring MVC builds up in the web context.
Summary : This blog tells the basic process of spring MVC and its relationship to the web. This knowledge content helps to understand the use of spring MVC. But also for the better use of it. See you next!

Spring Learning Summary (2.1)-spring MVC

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.