Spring Web common interview questions SpringMVC summary and some questions in the interview. Detailed explanation of the SpringMVC startup process

1. Web container initialization process

First initialize the listener, then the filter, then the servlet.

2. IOC container relationship in Spring MVC project

When the Web container starts, the ContextLoaderListener is notified to initialize the root IOC container. The default is the WebApplicationContext instance, which stores Bean objects except the Web layer. Then the DispatcherServlet initializes the WebMVC context and establishes its own IOC container as a sub-container of the root IOC container.

Third, the working process of DispatherServlet

 

 

Process 
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, generates a processor object and a processor interceptor (if any) and returns it to the DispatcherServlet. 
4. DispatcherServlet calls HandlerAdapter processor adapter 
5. HandlerAdapter calls specific processor (Controller, also called back-end controller) after adaptation. 
6. Controller execution completes and returns ModelAndView 
7. HandlerAdapter returns the controller execution result ModelAndView to DispatcherServlet 
8. DispatcherServlet passes ModelAndView to ViewReslover view parser 
9. ViewReslover returns to specific View after parsing 
10. DispatcherServlet renders view according to View (that is, fills in model data into view). 
11. DispatcherServlet responds to the user
Fourth, the advantages of Spring MVC design

Five, the main difference between SpringMVC and Struts2?

The entrance of springmvc is a servlet, that is, a front-end controller, and the entrance of struts2 is a filter.
springmvc is based on method development, and parameters are passed through method parameters, which can be designed as a single instance or multiple instances (single instance is recommended )
Struts uses the value stack to store request and response data, and accesses data through OGNL.  Springmvc parses the content of the request object into method parameters through the parameter parser, encapsulates the response data and pages into ModelAndView objects, and finally converts the model data. Transferred to the page through the request object. The Jsp view resolver uses jstl by default. 
 

Guess you like

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