Spring MVC
is actually a Java implementation of the Web MVC design pattern of the request-driven type of the lightweight web framework, is to use the MVC architecture pattern idea, the web layer decoupling, so based on the request-driven refers to the request-response model.
The front controller is Dispatcherservlet, and the application control is actually two parts: the processor mapper (Handler Mapping) for the management of the processor and view Resolver for the view. The page controller is the controller interface, including some ModelAndView handleRequest (request, response)
implementations, that is, the Pojo class. Provides flexible data Elliott, formatting and data binding.
Spring MVC uses
Simple web-level unit testing, flexible URL-to-page controller mapping, flexible data validation formatting and data binding.
Spring MVC Architecture
This framework of MVC is based on the request-driven framework and is also used by the front-end controller pattern, which is distributed to the response controller according to the request mapping rules.
Spring MVC processing Request Flow
- First, the user sends a request-the front-end controller that determines the page controller based on the requested information, such as a URL.
- After the page controller receives the request, it processes the function and returns a Modelandview.
- The front controller reclaims control and renders according to the returned logical view.
- The front controller returns the response to the user.
Spring MVC Core Process
First, the user sends the request-->dispatcherservlet, the front controller receives the request not to carry on the processing, but entrusts to the other parser to handle, as the unified access point, carries on the global flow control;
Dispatcherservlet-->handlermapping, Handlermapping will map the request to the Handlerexecutionchain object (which contains multiple handlerinterceptor interceptors), and it is easy to add a new mapping strategy through this policy mode;
The Dispatcherservlet-->handleradapter,handleradapter will package the processor as an adapter to support multiple types of processors, the adapter design mode application, which makes it easy to support many types of processors;
Handleradapter--> Processor function Processing method call, Handleradapter will be based on the results of the adaptation to call the real processor function processing method, complete the function processing, and return a Modelandview object (including model data, logical view name);
Modelandview logical View name---Viewresolver, Viewresolver will parse the logical view name into a specific view, through this strategy mode, it is easy to replace other view technology;
view--> rendering, the view is rendered according to the model data passed in, the model is actually a map data structure, so it is easy to support other view technology;
Returns control to Dispatcherservlet, which is returned by the Dispatcherservlet response to the user, to the end of this process.
This section is from: The Tao Blog
Mostly recently in the making, so one side of the practice to try to write a reference. Write some more practical content in the back.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Development-Spring MVC Learning