Working principle
Above is the schematic diagram of SPRINGMVC's work:
1, the client sends an HTTP request to the Web server, the Web server parses the HTTP request, If the request mapping path (specified in Web. xml) matches the Dispatcherservlet, the Web container will forward the request to Dispatcherservlet.
2. After receiving this request, Dipatcherservlet will find the processor (Handler) processing the request based on the requested information (including URL, HTTP method, request packet header and request parameter cookie, etc.) and handlermapping configuration.
3-4, Dispatcherservlet according to handlermapping find corresponding handler, the processing right to handler (handler will be specific processing to package), Then the specific handleradapter to the handler to make a specific call.
5, Handler will return a Modelandview () object to Dispatcherservlet after the data processing is completed.
6. Handler return Modelandview () just a logical view is not a formal view, Dispatchersevlet transforms a logical view into a real views view by Viewresolver.
7, dispatcher through the model to parse out the parameters in the Modelandview () and finally show the full view and return to the client.
What is the operation mechanism? Control Invocation (cont.)
Then for the supplement of (II): The main point is to summarize the control of the key processing logic operation;
The key to control processing is that a handler in each Handlermapping object is matched by the requested URL in the Dispatcherservlet handlermappings collection, After a successful match, the handler processing connection Handlerexecutionchain object is returned. This Handlerexecutionchain object will contain multiple user-defined Handlerinterceptor objects.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/** * Return The Handlerexecutionchain for this request. * <p>tries All handler mappings in order. * @param request Current HTTP request * @return The Handlerexecutionchain, or <code>null</code> if no ha Ndler could be found |