Lifecycle of spring MVC
Before using spring MVC, we must understand the spring MVC process, for example:
See some previous instructions: (The handlermapping, handleradapter, handlerexceptionresovler, and viewresolver described below have an order attribute, because each of these interfaces can register multiple implementations, order indicates their execution order. The smaller the order, the more advanced the execution. Generally, the first execution will not be executed after matching)
Dispatcherservlet: the front-end controller of spring MVC that takes over requests from the client.
Handlermapping: dispatcherservlet uses it to process the ing between client requests and various controller processors.
Handleradapter: handlermapping will call the method to be executed in the Controller Based on it
Handlerexceptionresolver: In the spring MVC processing process, if an exception is thrown, it will be handed over for exception processing.
Viewresolver: handleradapter packs the call return values in the controller into modelandview. viewresolver checks the view. If the view is a string, it processes the string and returns a real view, if a view is a real view, it will not be handed over to it for processing. Why can a view be a string or a view? The following will explain how it works.
View: corresponds to V in MVC. This interface has only one render method for View display.
Modelandview solves the doubts about viewresoler or the image below. The view attribute in this class is of the object type. It can be a view name or an actual view, we can see the source code clearly.
Private object view;
Public void setviewname (string viewname ){
This. view = viewname;
}
Public String getviewname (){
Return (this. View instanceof string? (String) This. View: NULL );
}
Public void setview (view ){
This. view = view;
}
Public View getview (){
Return (this. View instanceof view? (View) This. View: NULL );
}
Spring MVC Flowchart
If the image is incomplete or cannot be viewed clearly, click the following link. Because the image is too large, the process entry starts from the client at the top of the center.
Http://pic002.cnblogs.com/images/2012/267998/2012010623530925.png