Execution process and component description of SpringMVC

1. SpringMVC execution process

1. The user request is sent to the front controller DispatcherServlet

2. DispatcherServlet calls the handler mapper HandlerMapping after receiving the request

3. The processor mapper finds the corresponding processor according to the request URL, generates the processor object and the processor interceptor (if any, generates it together), and returns it to the DispatcherServlet together

4. DispatcherServlet calls the specific processor Controller through the processor adapter HandlerAdapter

5. Execute the processor Controller (also called the backend processor)

6.Controller returns ModelAndView

7.HandlerAdapter returns the execution result ModelAndView of Controller to DispatcherServlet

8. DispatcherServlet passes ModelAndView to the view resolver ViewReslover

9. ViewReslover returns the specific View after parsing

10. DispatcherServlet renders the View (that is, the model data is filled into the view)

11. DispatcherServlet responds the rendered view to the user

2. Description of SpringMVC components

1. DispatcherServlet: front controller

When a user request arrives at DispatcherServlet, it is equivalent to C in the MVC pattern. DispatcherServlet is the control center of the entire process. It calls other components to handle various requests of users. The existence of DispatcherServlet reduces the coupling of other components.

2.HandlerMapping: handler mapper

HandlerMapping is responsible for finding the corresponding handler according to the request URL. springMVCt provides different mappers to implement different mapping methods, such as: xml configuration files, implemented through interfaces, and annotations.

3.HandlerAdapter: handler adapter

Execute the processor through HandlerAdapter, which is the application of the adapter mode, and can execute more types of processors by extending the adapter

4.ViewResolver: View resolver

The ViewResolver is responsible for processing the resulting View view. First, it parses the logical view name into the physical view name, that is, the specific page address, then generates the View view object, and finally renders the View. Finally, the processing result is displayed to the user through the page.

5.Handler: handler

Handler is a back-end controller relative to the front-end controller. It handles the specific requests of users under the control of dispatcherServlet. Since Handler involves the specific business requests of users, programmers are generally required to develop Handlers.

6.View: view

SpringMVC provides support for many View view types, but the most commonly used is jsp.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324731126&siteId=291194637