Joke Collection Website - Public benefit messages - java urgently needs an explanation of the working principle of SpringMVC and its flow chart
java urgently needs an explanation of the working principle of SpringMVC and its flow chart
Spring workflow description
?1. The user sends a request to the server, and the request is captured by the Spring front-end control Servelt DispatcherServlet;
?2.?DispatcherServlet responds to the request The URL is parsed and the requested resource identifier (URI) is obtained. Then according to the URI, call HandlerMapping to obtain all related objects configured by the Handler (including the Handler object and the interceptor corresponding to the Handler object), and finally return it in the form of a HandlerExecutionChain object; 3.? DispatcherServlet selects a suitable one based on the obtained Handler. HandlerAdapter. (Note: If the HandlerAdapter is successfully obtained, the preHandler(...) method of the interceptor will start to be executed at this time)
4. Extract the model data in the Request, fill in the Handler input parameters, and start executing the Handler (Controller). During the process of filling in the Handler's input parameters, Spring will help you do some additional work according to your configuration:
?HttpMessageConveter: Convert the request message (such as Json, xml and other data) into an object, Convert the object into the specified response information
?Data conversion: Convert the request message to data. For example, String is converted into Integer, Double, etc.
?Data radicalization: Format the data of the request message. Such as converting strings into formatted numbers or formatted dates, etc.
?Data verification: Verify the validity of the data (length, format, etc.), and store the verification results in BindingResult or Error 5. ?Handler execution After completion, return a ModelAndView object to DispatcherServlet; 6. Based on the returned ModelAndView, select a suitable ViewResolver (must be a ViewResolver registered in the Spring container) and return it to DispatcherServlet; 7. ViewResolver combines Model and View, To render the view
? 8. Return the rendering result to the client.
Spring workflow description
Why does Spring only use one Servlet (DispatcherServlet) to handle all requests?
?For details, see J2EE Design Pattern - Front-end Control Pattern
Why does Spring use HandlerMapping and HandlerAdapter in combination to handle Handler?
In line with the single responsibility in object-oriented In principle, the code structure is clear, easy to maintain, and most importantly, the code is highly reusable. For example, HandlerAdapter may be used to handle multiple Handlers.
- Related articles
- What's the telephone number of the labor bureau?
- How to write the specific content of the postgraduate adjustment email contact tutor, and ask the great god for advice.
- How to turn off Apple computer to receive short messages?
- Taobao SMS registration verification code can not be received.
- Gionee's mobile phone. I encrypted the information. How can I find it?
- Is it true that Netease takes five yuan for research and answer questions?
- How to reduce the font in SMS?
- Is there a charge for OA mobile version access?
- South Korea Naver's mobile phone verification code
- I wish you pass the exam.