SpringMVC study notes -10 detailed execution process

Take dynamic resource request as an example to analyze the execution process of SpringMVC:

1. The request sent by the browser is distributed to DispatcherServlet ( <url-pattern> configured in web.xml) through Tomcat .

2->3. DispatcherServlet (central dispatcher) will hand over the request to HandleMapping (processor mapper), get the Controller object ( controller = ctx.getBean() ) used to process the request from the SpringMVC container , and transfer the Controller The object is stored in the HandlerExecutionChain (processor execution chain).

Object: Store Controller List<HandlerInterceptor> interceptorList: All interceptors

4->7: DispatcherServlet handed the processor object in HandlerExecutionChain to the HandleAdaptor (processor adapter) object, let the processor adapter be responsible for calling the processor method, and get the return value ModelAndView.

8->9. DispatcherServlet delivers ModelAndView to the view resolver object (there can be more than one). The view parser is responsible for splicing into a complete view path, and creating a View object to specify the view, not just a string representation; and handing the View object to the DispatcherServlet. [ModelAndView object has setViewName and setView, the parameter required by setView is this View object]

10->11. DispatcherServlet uses the View object, puts the Model into the request scope, and executes the forward request of the view, and the request ends.

All parts rely on DispatcherServlet for functional coordination, so it is also called the central scheduler.

Guess you like

Origin blog.csdn.net/qq_39304630/article/details/113061812