Spring MVC framework request processing flow and architecture

A request processing flow Spring MVC framework
Here Insert Picture Description
analysis of this figure, it is found Spring MVC also be designed based on a request-driven Web framework, and also uses a front-end controller mode, and then distributed according to the control request corresponding page mapping rules device (processor) for processing, its specific analysis following process steps:

First, the user sends a request to the front-end controller (DispatcherServlet), the front end of the controller requests information (such as URL) determined according to which page request controller (Controller) for distributed processing. Step 1 corresponds to the figure above.
After 2 page controller receives a request, performs service processing, returns after a ModelAndView processed. 3,4,5 step corresponds to the above figure.
3 front controller transfers control to recover, and then returned in accordance with the logical view name and choose the real view from the view resolver, the model data into the display for rendering thereof. 6 and 7 correspond to the steps in the figure above.
4 front-end controller again to take back control, the response returns the results to the browser client, bringing the entire process ends. Step 8 corresponds to the figure above.

Architecture two Spring MVC framework
Here Insert Picture Description

We found by the figure, in response to receiving the request and returns, many components of Spring MVC effort with their duties to complete the process work. Throughout the framework, Spring MVC is received by a front-end controller for all requests and specific work commissioned to deal with the other components, so that DispatcherServlet at the heart of the organization which is responsible for coordinating the different components to complete processing the request and returns the response results.

According to Spring MVC request processing, we specifically analyze each component is responsible for the content of the work:
1 client makes an HTTP request, Web application server receives the request. The route map matching DispatcherServlet request, the request is forwarded to the Web container DispatcherServlet treatment;
after 2 DispatcherServlet get request, the information request (the URL, request parameters, HTTP method and the like), and arranged to find a processing request HandlerMapping processor (Handler);
. 3 after DispatcherServlet find the appropriate Handler, by HandlerAdapter of encapsulated Handler, then a uniform adapter interface calls Handler. HandlerAdapter can be understood as people actually use the Handler to work.
4 In the period before requesting information actually reach the call processing method Handler, Spring MVC also completed a lot of work, it will request information in a certain way and converted into the reference bound to the request method, for the argument objects It will perform the data conversion, data formatting and data checking. After these are done, the last truly call processing method Handler of the corresponding business logic processing.
After completion of service processing processor 5, a return to the DispatcherServlet ModelAndView object, which contains the model name and the logical view data.
6 DispatcherServlet logical view name through ViewResolver resolves to a true view object View, can be a JSP, HTML, XML, PDF, JSON , etc., 7 7 Spring MVC can be flexibly configured, will be introduced in the future.
After getting a real view object, DispatcherServlet View will be on view rendering model data ModelAndView object.
8 finally obtain a response message client.

Published 133 original articles · won praise 53 · views 20000 +

Guess you like

Origin blog.csdn.net/weixin_43599377/article/details/103078887
Recommended