Interview What is SpringMVC and how it works

1. What is Spring MVC?

   It is a design pattern of Spring, a framework.


2. What does MVC stand for?

        M stands for model, which is the abbreviation of model, which refers to the business logic layer model. V stands for view, which is the abbreviation of View, and refers to the view layer. C is the abbreviation of controller! Refers to the control layer.


working principle


1. The user sends a request to the front controller DispatcherServlet.


2. DispatcherServlet receives a request to call HandlerMapping processor mapper.


3. The processor mapper finds the specific processor (can be searched according to the xml configuration and annotation), generates the processor object and the processing interceptor (if there is one), and returns it to the DispatcherServlet.


4. DispatcherServlet calls HandlerAdapter processor adapter.


5. The HandlerAdapter calls a specific processor (Controller, also called a back-end controller) after adaptation.

6. Controller returns to ModelAndView after the execution is completed.


7. HandlerAdapter returns the controller execution result ModelAndView to DispatcherServlet.

8. DispatcherServlet passes ModelAndView to ViewReslover view parser.


9. ViewReslover returns a specific View after parsing.


10. DispatcherServlet renders the view according to the View (that is, fills the model data into the view).

11. DispatcherServlet responds to the user.


DispatcherServlet: It is the front controller, which is responsible for the center of the entire process control, the central scheduler, which controls the execution of other components, and uniform scheduling. Reduce the coupling of various components and increase scalability.

HandlerMapping: Mapping processors, different mapping methods can be realized by extending the processor mapper! For example: configuration files, interface implementation, and annotations are all mapped by him.

HandlerAdapter: Adapter handler.

ViewResolover: view resolver, such as parsing jsp, etc.

Guess you like

Origin blog.csdn.net/weixin_69218754/article/details/130779707