???????
????Controller???????????????????????????????????????????????????????????е???????????????????????????
????Sping MVC3.2?汾??????????????????仯??????????????????????????????Ч??
??????????4.1?汾????????Controller??????????????????òο?????Spring MVC Showcase(https://github.com/spring-projects/spring-mvc-showcase)?????????汾??????4.1.0???????????????????????????У??????????μ???????ο???
?????????IDE??IntelliJ IDEA13????????????Eclipse???ú????????????
?????????
???????maven?????????????????£?
??????Controller??????????д??????Spring config????????????src/main/java?е?.xml
????????????£?Spring Mvc context?????ò????
????????С??鶼??????????(e.g spring-mvc.xml???????ú??????????????showcase??web?????y?
????WEB-INF
????web.xml (???)
????spring ??????У?
????root-context.xml ????????????????servlet??filter?????????????
????appServlet ??????
????controllers.xml?????????Controller?????????
????servlet-context.xml ?????????????servlet?????????
????Spring mvc???Servlet?????????????????????????
1 <web-app xmlns="http://java.sun.com/xml/ns/javaee"
2
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
5 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
6
7 version="3.0">
8
9 <!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
10
11 <context-param>
12
13 <param-name>contextConfigLocation</param-name>
14
15 <param-value>/WEB-INF/spring/root-context.xml</param-value>
16
17 </context-param>
18
19 <!-- Creates the Spring Container shared by all Servlets and Filters -->
20
21 <listener>
22
23 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
24
25 </listener>
26
27 <filter>
28
29 <filter-name>csrfFilter</filter-name>
30
31 <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
32
33 <async-supported>true</async-supported>
34
35 </filter>
36
37 <filter-mapping>
38
39 <filter-name>csrfFilter</filter-name>
40
41 <url-pattern>/*</url-pattern>
42
43 </filter-mapping>
44
45 <!-- Processes application requests -->
46
47 <servlet>
48
49 <servlet-name>appServlet</servlet-name>
50
51 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
52
53 <init-param>
54
55 <param-name>contextConfigLocation</param-name>
56
57 <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
58
59 </init-param>
60
61 <load-on-startup>1</load-on-startup>
62
63 <async-supported>true</async-supported>
64
65 </servlet>
66
67 <servlet-mapping>
68
69 <servlet-name>appServlet</servlet-name>
70
71 <url-pattern>/</url-pattern>
72
73 </servlet-mapping>
74
75 <!-- Disables Servlet Container welcome file handling. Needed for compatibility with Servlet 3.0 and Tomcat 7.0 -->
76
77 <welcome-file-list>
78
79 <welcome-file></welcome-file>
80
81 </welcome-file-list>
82
83 </web-app>