Request execution request SpringMVC

We configured the first DispatcherServlet class in web.xml

We request sent by the server first enters service method but our DispatcherServlet no service class method, so the method is performed automatically parent class HttpServlet abstract class parent class's parent class

Here Insert Picture Description
Method service class HttpServlet the last request and response will be spread doGet method, the principle of proximity spread doGet parent class in FrameworkServlet DispatcherServlet

Here Insert Picture Description

Directly to the request and response method processRequest incoming
Here Insert Picture Description
request has entered doService method, where the method is doService DispatcherServlet class rewritten to achieve, so we enter doService method DispatcherServlet class
Here Insert Picture Description
in doService approach, our request was introduced to many attribute value, for example (shown in two thin red circle) the IoC container, various parsers, etc., then the incoming request doDispatch method
Here Insert Picture Description
we came doDispatch method, first define a requesting processor to perform chain mapperHandler, then define a ModelAndView Object mv, mapperHandler performed getHandler method handler for this request allocation request processor (i.e., all of the method in Controller layer), and then returns the view back mv

Then define an adapter ha, Handler format is not fixed, it is necessary to do fit HandlerAdapter processing the request

ha call handle method returns an object ModelAndView mv, where the real call handler method Controller layer

The last execution method processDispatcherResult

Here Insert Picture Description
processDispatcherResult method, mv objects, the incoming requests and responses render method

Here Insert Picture Description
In the render method DispatcherServlet in, access to the target view, and enter the view object's render method for
Here Insert Picture Description
this renderMergedOutputModel method refers to the return to the page and the target method results together, is an abstract method in this class, InternalResourceView implement the method, we point go
Here Insert Picture Description
last visited the target page request forwarded by the way
Here Insert Picture Description

Use redirect redirect the way, is not accessible jsp page in our WEB-INF, and only through the forward (forward the request) way

Published 101 original articles · won praise 3 · Views 2238

Guess you like

Origin blog.csdn.net/S_Tian/article/details/104365603