Catalogue
First, preface
Two, spring MVC core class and interface
Third, spring MVC core flowchart
Iv. Spring MVC dispatcherservlet Description
V. Description of Spring MVC parental context
Six, springmvc-mvc.xml configuration file fragment explanation
Vii. how spring MVC accesses static files, such as Jpg,js,css.
How the spring MVC request maps to a method in a specific action.
Ix. interceptors in spring MVC:
X. How spring MVC uses interceptors.
Xi. How spring MVC implements global exception handling.
12. How spring MVC Records global exceptions to the log.
13. How to do junit Unit test for action in Spring3 MVC.
14. Spring MVC forwarding and redirection
XV, Spring MVC handles AJAX requests
16. Spring MVC instructions for writing several configuration files
17. How spring MVC obtains spring-managed beans
18. Spring MVC Multi-View Controller
19, <mvc:annotation-driven/> What exactly did the work
20, this article Springmvc.xml configuration file is the core, here to a download address
Description: The author is the original author of the article, reproduced please indicate the source: This article address: http://elf8848.iteye.com/blog/875830
There are q-q group exchanges, you are welcome to join: 34292021
First, preface:
Hello everyone, Spring3 mvc is a very good MVC framework, since it was released in the 3.0 release, now there are more and more teams choosing SPRING3 MVC. SPRING3 MVC structure is simple, should be the sentence: Simple is the United States, and he is strong and flexible, performance is also excellent.
The official download URL is: http://www.springsource.org/download (this article uses the Spring 3.0.5 version)
Struts2 is also an excellent MVC architecture, with many advantages such as good structure. But here is the disadvantage, Struts2 because the use of value stack, OGNL expression, struts2 tag library, etc., will lead to the performance of the application degradation. STRUTS2 multi-layer interceptors, multi-instance action performance are very good. You can refer to an article I wrote about the comparison between spring MVC and Struts2 and Servlets http://elf8848.iteye.com/admin/blogs/698217
Advantages of SPRING3 MVC:
1, Spring3 MVC Learning difficulty is less than the struts2,struts2 of unnecessary functions too much. Oh, of course this is not the deciding factor.
2, Spring3 MVC is easy to write a good performance program, Struts2 to be careful to write good performance program (refers to the MVC part)
3, Spring3 MVC flexibility is you can not imagine, Spring's extensibility is legendary, Spring3 MVC certainly will not lag behind, not because of the use of the MVC framework and feel any restrictions.
STRUTS2 's many advantages: a little ... (hehe, isn't it unfair.) )
Many articles at the beginning of the total to blow some cows, to attract the reader's attention, the reader's appetite to adjust, so that everyone is interested in looking back. There is no exception to this article. But make sure you don't regret it when you see it.
Reprint please indicate the source: this address: http://elf8848.iteye.com/blog/875830
second, the core class and interface:
Let's take a look at some important interfaces and classes. Now do not know what they are do not matter, first mixed face ripe, for later know them to play a foundation.
Dispatcherservlet--Front Controller
Handlermapping interface--mapping of processing requests
Implementation classes for the Handlermapping interface:
simpleurlhandlermapping mapping a URL to a controller through a configuration file
defaultannotationhandlermapping maps a URL to a controller class via annotations
Handleradapter interface--mapping of processing requests
The Annotationmethodhandleradapter class, through annotations, maps a URL to the method of the Controller class
Controller interface--controllers
Since we have used the @controller annotation, the class that added the @controller annotation annotation can assume the responsibility of the Controller (Action),
So we don't have to use this interface.
Handlerinterceptor interface--Interceptor
Without graphs, we implement this interface ourselves to complete the work of the Interceptor.
Implementation class for the Viewresolver interface
The Urlbasedviewresolver class passes a configuration file and gives a view name to the
Internalresourceviewresolver class, than the above class, joined the JSTL support
View interface
Jstlview class
Localresolver interface
Handlerexceptionresolver interface--Exception handling
Simplemappingexceptionresolver Implementation Class
Modelandview class
No diagram.
Third, core flowchart
This picture is my personal painting, there is not rigorous place, we deal with the look. It's better than not watching.
Reprint please indicate the source: this address: http://elf8848.iteye.com/blog/875830
iv. Description of Dispatcherservlet
With spring MVC, configuring Dispatcherservlet is the first step.
Dispatcherservlet is a servlet, so you can configure multiple dispatcherservlet.
The Dispatcherservlet is the predecessor controller, which is configured in the Web. xml file. Interception of matching requests, servlet intercept matching rules to be self-defined, the interception of requests, according to certain rules distributed to the target controller (we write action) to deal with.
The "so-and-so rule": is different from the implementation class of which handlermapping interface you are using.
First example: XML code <web-app> <servlet> <servlet-name>example</servlet-name> <servlet-class> org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name