How Spring MVC Works

Source: Internet
Author: User

SPRINGMVC Framework Introduction

1) Spring MVC is a follow-up product of Springframework, which has been integrated into spring Web flow.

The Spring framework provides a full-featured MVC module for building WEB applications. Using spring's pluggable MVC architecture, you can choose to use a built-in spring web framework or a WEB framework such as Struts. With the policy interface, the Spring framework is highly configurable and includes a variety of view technologies, such as JavaServer Pages (JSP) technology, Velocity, Tiles, IText, and POI. The Spring MVC framework does not know which view to use, so it does not force you to use only JSP technology.

Spring MVC separates the roles of controllers, model objects, dispatchers, and handler objects, and this separation makes them easier to customize.

2) Spring's MVC framework consists mainly of Dispatcherservlet, processor mapping, processor (Controller), view parser, and view.

SPRINGMVC schematic diagram

650) this.width=650; "style=" Border-bottom:medium none;border-left:medium none;border-top:medium none;border-right: Medium none; "align=" Middle "src=" http://img.my.csdn.net/uploads/201211/16/1353059506_5137.jpg "width=" 712 "height= "427"/>

Springmvc Interface Interpretation

Dispatcherservlet Interface:

Spring provides a front-end controller that all requests have to be distributed uniformly. Before Dispatcherservlet will distribute the request to the spring controller, it needs to navigate to the specific controller using the handlermapping provided by spring.

Handlermapping Interface:

Ability to complete customer requests to controller mappings.

controller interface:

controller will process User request, which is consistent with the role that struts action plays. Once the controller has finished processing the user request, the Modelandview object is returned to the Dispatcherservlet front-end controller, and the model and view are included in Modelandview.

from a macro point of view , Dispatcherservlet is the controller for the entire Web application, and from a microscopic consideration, the controller is a director in a single HTTP request process, while the Modelandview is the model and view that is returned during the HTTP request.

Viewresolver Interface:

Spring provides a view parser (Viewresolver) to look up a View object in a Web app, rendering the result to the customer.

SPRINGMVC Operating principle

2. Query one or more handlermapping by the Dispatcherservlet controller to locate the controller

4. After the controller invokes the business logic processing, it returns Modelandview

6. The view is responsible for displaying the results to the client

Dispatcherservlet is the core of the whole spring MVC. It is responsible for receiving the HTTP request organization to coordinate the various components of spring MVC. Its main work has the following three items:

1. Intercept URL requests that match a specific format.
2. Initialize the webapplicationcontext that corresponds to the Dispatcherservlet context and associate it with the business layer, webapplicationcontext of the persistence layer.
3. Initialize the various components of spring MVC and assemble them into the dispatcherservlet.

How Spring MVC Works

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.