Spring MVC process Detailed

 

Spring MVC flow chart

       Left to right, the client initiates a user request to enter into the http servlet container form, a servlet container Endpoint Data to resolve the object, the object contains the requested URL Endpoint, HttpHeader read and parsed by the body or data flow, and then enters the user custom filter, the filter may process the user request, and after a plurality of filter processing is completed, it proceeds to the DispatcherServlet spring MVC inlet, after first access to frequently used parser, to parse such MultipartResolver bytes uploaded stream, and some string k: v encapsulated object read out, the controller for the subsequent reception of this layer from the parser is to find out the process by requesting the URL handler, the handler is our own definition controller, since we Notes in the Controller of RequestMapping, url mapping in the startup process, it will be registered by RequestMapping method Controller corresponding to HandlerMapping, if the request can not be found in the corresponding HandlerMapping the Handler, will report a 404 error, otherwise, will enter the intercept Ha device ndlerInceptor, we can print the log-related operations, such as identity authentication interceptor, the interceptor after, spring will bind the data, and RequestMapping annotated method parameter binding, the return reflection method call our Controller , when we entered the specific method body in the Controller, the Controller method body can call the corresponding service business processes, and then out of the Controller, start creating ModelAndView object, rendering the page after entering the process, in fact, the Alternatively a variable data template, then return to render it passes DispatcherServlet, filter subsequent processing, returns the HTTP response to the client ultimately formed by the Servlet container, which is spring MVC overall process.

S ervlet response to a user request process container (Simple Version)

        Java on the Http processing is done by the Servlet, however, servlet by Servlet container management. When over a Http request, receiving the first Servlet container, the container Http responsible for parsing and creating instances Servlet Request and Response (i.e. HttpServletRequest and HttpServletResponse example in which the object encapsulates HttpServletRequest Http request information). Servlet container calls the servlet (HttpServlet's service method) Request and Response object to most parameters passed to serlvet, servlet and then call the relevant methods of acquiring Request Http request information (information parsed Servlet container). Then call the relevant methods Response servlet to generate a response message client. Servlet container final results to the appropriate customers.

 

Guess you like

Origin blog.csdn.net/m0_37732829/article/details/90406053