Introduction to Spring MVC (i)

Source: Internet
Author: User

What is Spring MVC

Before learning something, we must know roughly what this thing is, what it can do, and why it is used.

Spring MVC is an open source platform, a spring-based MVC framework that supports the development of WEB applications based on Java. The MVC architecture facilitates the development of flexible, low-coupling WEB application components.

M (model) models, application data carriers. are usually some POJO.

V (view) view, used to render data for some models, typically used to generate an explanatory HTML for the user's browser.

The C (Controller) controller, which processes the user's request and builds the appropriate model, and then gives the view rendering.

The advantages of Spring MVC:

(1) easy to use;

(2) can easily develop a good performance of the program;

(3) Flexible, easy to expand;

(4) Having some characteristics of Spring;

(5) Support restful style;

Disadvantages of Spring MVC:

(1) It is difficult to operate independently from the container;

(2) need to write some corresponding web. XML configuration;

Spring MVC Request Process

  

(Spring MVC Request processing process)

The functional description of several components involved in the process:

    Dispatcherservlet (Front Controller): receives a user request and returns the result of the request. It controls the entire execution process, schedules individual components, and reduces coupling between components, like a team's organization.

    handlermapping (processor mapper): According to the user's request URL, according to the XML configuration or annotations to find the corresponding processor Handler.

    Handleradapter (processor adapter): The method in the calling processor is completed based on the Handler found by the mapper.

    Handler (processor): Handles the primary logic of the request, returning model data and views.

   viewresolver (View parser): parses a specific view. Resolves the logical view name to a true view through view in Modelandview.

The following steps are required:

1: The request is blocked by the front-end controller (dispatcherservlet) when the client requests

2: Front Controller (dispatcherservlet) Request Processor Mapper (handlermapping) Lookup Handler

3: Processor mapper (handlermapping) locates corresponding handleraccording to configuration, may contain multiple interceptor interceptors, return to front Controller

4: Front Controller (dispatcherservlet) Request processor Adapter (Handleradapter) to perform the corresponding handler

5: Adapter is assigned to the corresponding handler processor

return Modelandview object to processor adapter after 6:handler processor finishes executing

7: The processor adapter accepts the return result of the handler processor and returns the result to the front-end controller (dispatcherservlet)

8: Front Controller (Dispatcherservlet) receives the data and view information returned by the processor adapter, Requests the view resolver, resolves the corresponding view

9: The view resolver matches the corresponding view results according to the views information, back to the front-end controller

10: Front controller receives a specific view, renders the view , fills the model data into the view view, and produces the final view

11: Front Controller returns request result to client

Introduction to Spring MVC (i)

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.