Workflow of SpringMVC

The workflow is:
1. The user sends a request to the front-end controller DispatcherServlet
2. The DispatcherServlet receives the request and calls the HandlerMapping handler mapper.
3. The processor mapper finds a specific processor according to the request url, generates a processor object and a processor interceptor (the two form a HandlerExecutionChain), and returns it to the DispatcherServlet.
4. The DispatcherServlet calls the processor through the HandlerAdapter processor adapter
. 5. The execution processor (Controller, also called the back-end controller).
6. Controller execution completes and returns to ModelAndView
7. HandlerAdapter returns the controller execution result ModelAndView to DispatcherServlet
8. DispatcherServlet passes ModelAndView to ViewReslover view parser
9. ViewReslover returns to the specific View after parsing
10. DispatcherServlet renders the View (that is, fills in model data) into view).
11. DispatcherServlet responds to the user

In short, SpringMVC uses the DispatcherServlet front-end controller (also called the central scheduler, I think the central scheduler can better reflect its role), to call the three major pieces of mvc: Controller, Model, View. This ensures that each component of MVC is only coupled with the DispatcherServlet, and runs independently of each other, which greatly reduces the coupling of the program.

Let's talk about how the SpringMVC framework implements the MVC pattern.
Note that SpringMVC does not involve the implementation of the Controller interface specification. SpringMVC implements the Controller layer by calling Handler.

SpringMVC uses the adapter mode, the front controller uses HandlerAdapter to call different Controllers, and then the Controller calls the Model to generate
the data model; the generated data model will be returned to the front controller again, and the front controller decides to use a different template The engine renders the page.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326765864&siteId=291194637