Introduction and workflow of SpringMVC

Schematic diagram

SpringMvc workflow

work process

  1. The user sends a request to the front controller DispatcherServlet.
  2. DispatcherServlet will call the HandlerMapping processor mapper after receiving the request.
  3. The processor mapper finds a specific processor (you can find it according to the xml configuration and annotations), generates a processor object and a processor interceptor (if there is one) and returns it to the DispatcherServlet.
  4. DispatcherServlet calls the HandlerAdapter processor adapter.
  5. HandlerAdapter calls a specific processor (Controller, also called back-end controller) through adaptation.
  6. Controller execution is complete and returns to ModelAndView, which returns to the processor adapter.
  7. HandlerAdapter returns the controller's execution result ModelAndView to DispatcherServlet.
  8. DispatcherServlet passes ModelAndView to ViewReslover view resolver.
  9. ViewReslover returns to the specific View after parsing.
  10. DispatcherServlet renders the view according to the View (that is, fills the model data into the view, jstl, etc.).
  11. DispatcherServlet responds to the user.

Component description

  1. DispatcherServlet: The front controller, also known as the central controller, is the control center of the entire request response, and the invocation of the components is uniformly scheduled by it. (Only responsible for accepting requests and forwarding requests)
  2. HandlerMapping: The processor mapper, which maps to the corresponding back-end processor Handler according to the URL accessed by the user. (Only responsible for URL mapping, not executing, but telling the result to the front controller)
  3. HandlerAdapter: The processor adapter, which calls the method in the back-end processor and returns the logical view ModelAndView object.
  4. ViewResolver: View resolver, which resolves the ModelAndView logical view into a specific view (such as JSP).
  5. Handler: The back-end processor, which processes user specific requests, which is the Controller class we wrote.

Guess you like

Origin blog.csdn.net/root_zhb/article/details/109508090