SpringMVC around a central servlet, which is DispatcherServlet dispatch requests and provide other functions, DispatcherServlet inherited from HttpServlet base class.
As shown works as follows:
When the pre-initiation request is intercepted request controller generates a proxy request according to the request parameters, the request to find the corresponding actual controller, the controller processing the request, creating a data model, access to the database, the model response to the central controller that controls uses a model and view the results of rendering the view, will return the results to the central controller, then the result returned to the requestor.
SpringMVC implementation of the principle :
The figure is a flowchart SpringMVC more complete, a solid line indicates SpringMVC technology framework does not need to write their own, the broken line represents to write their own.
Simple analysis of the above scheme:
- It represents DispatcherServlet front controller, the whole SpringMVC control center. User makes a request, DispatcherServlet accept the request and intercepts the request.
- We assume that the request is: http: // localhost: 8081 / SpringMVC / hello
- The above request is split into three parts
- http: // localhost: 8081 is a domain name server
- SpringMVC is deployed on the server's web site
- hello indicates that the controller
- HandlerMapping processor mapping. DispatcherServlet call HandlerMapping, HandlerMapping url look Handler upon request.
- HandlerExecution shows a specific handler, with its main role is to find a controller according to url, url above is to find the controller as hello.
- HandlerExecution transmitting the analysis information to DispatcherServlet, mapping controller resolver.
- HandlerAdapter adapter indicates that the processor, which performs Handler to specific rules.
- Handler let specific Controller to perform.
- Controller The specific implementation information back to HandlerAdapter, such ModelAndView.
- The view logic HandlerAdapter or model name passed to DispatcherServlet.
- DispatcherServlet call the view resolver (ViewResolver) to resolve the logical view name HandlerAdapter transfer.
- View resolver resolves the logical view name passed DispatcherServlet.
- According DispatcherServlet view results view parser, call the specific view.
The results view patcherServlet view parser, call the particular view.- The final view presented to the user.