Detailed explanation and simple configuration of SpingMVC Workflow
First, let's take a look at its entire invocation process:
1. The user sends the request to the front-end controller DispatcherServlet, which manages the whole life cycle of the request, from the request to the response.
2. DispatcherServlet receives a request to call the HandlerMapping processor mapper.
3. Find the specific processor from the processor mapper, generate the processor object and the processor interceptor (if any) and return it to DispatcherServlet.
4. DispatcherServlet calls HandlerAdapter processor adapter
5. HandlerAdapter calls the specific processor (Controller, also known as the back-end controller) after adaptation.
6. Return ModelAndView after Controller execution is completed
7. HandlerAdapter returns the controller execution result ModelAndView to DispatcherServlet
8. DispatcherServlet passes ModelAndView to ViewReslover view parser
9. Return specific View after ViewReslover parsing
10. DispatcherServlet renders the view according to the View (populating the model data into the view).
11. DispatcherServlet responds to users
Let's unify a simple Demo to understand the basic quota configuration:
1. First, create a project through Maven, add Spring-web framework to the project, and automatically load spring-related dependent files and generate xml configuration files. Take a look at web.xml first.
ContextConfigLocation / WEB-INF/applicationContext.xml org.springframework.web.context.ContextLoaderListener dispatcher org.springframework.web.servlet.DispatcherServlet 1 dispatcher / 30 redirect.jsp
Dispartcher-servlet.xml file
IndexController
ApplicationContext.xml