SpringMVC principle, the implementation process

SpringMVC around a central servlet, which is DispatcherServlet dispatch requests and provide other functions, DispatcherServlet inherited from HttpServlet base class.

1570167567494.png

As shown works as follows:

When the pre-initiation request is intercepted request controller generates a proxy request according to the request parameters, the request to find the corresponding actual controller, the controller processing the request, creating a data model, access to the database, the model response to the central controller that controls uses a model and view the results of rendering the view, will return the results to the central controller, then the result returned to the requestor.

1570167624269.png

SpringMVC implementation of the principle :

Here Insert Picture Description

The figure is a flowchart SpringMVC more complete, a solid line indicates SpringMVC technology framework does not need to write their own, the broken line represents to write their own.

Simple analysis of the above scheme:

  1. It represents DispatcherServlet front controller, the whole SpringMVC control center. User makes a request, DispatcherServlet accept the request and intercepts the request.
  • We assume that the request is: http: // localhost: 8081 / SpringMVC / hello
  • The above request is split into three parts
  • http: // localhost: 8081 is a domain name server
  • SpringMVC is deployed on the server's web site
  • hello indicates that the controller
  1. HandlerMapping processor mapping. DispatcherServlet call HandlerMapping, HandlerMapping url look Handler upon request.
  2. HandlerExecution shows a specific handler, with its main role is to find a controller according to url, url above is to find the controller as hello.
  3. HandlerExecution transmitting the analysis information to DispatcherServlet, mapping controller resolver.
  4. HandlerAdapter adapter indicates that the processor, which performs Handler to specific rules.
  5. Handler let specific Controller to perform.
  6. Controller The specific implementation information back to HandlerAdapter, such ModelAndView.
  7. The view logic HandlerAdapter or model name passed to DispatcherServlet.
  8. DispatcherServlet call the view resolver (ViewResolver) to resolve the logical view name HandlerAdapter transfer.
  9. View resolver resolves the logical view name passed DispatcherServlet.
  10. According DispatcherServlet view results view parser, call the specific view.
    The results view patcherServlet view parser, call the particular view.
  11. The final view presented to the user.
Published 272 original articles · won praise 19 · views 20000 +

Guess you like

Origin blog.csdn.net/hello_cmy/article/details/105023466