Spring MVC

springmvc

一:配置web.xml

 1 <!-- 配置spring -->
 2     <context-param>
 3         <param-name>contextConfigLocation</param-name>
 4         <param-value>classpath:applicationContext.xml</param-value>
 5     </context-param>
 6     <listener>
 7         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 8     </listener>
 9     <!-- 字符编码过滤器 -->
10     <filter>
11         <filter-name>encodingFilter</filter-name>
12         <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
13         <init-param>
14             <param-name>encoding</param-name>
15             <param-value>UTF-8</param-value>
16         </init-param>
17     </filter>
18     <filter-mapping>
19         <filter-name>encodingFilter</filter-name>
20         <url-pattern>/*</url-pattern>
21     </filter-mapping>
22     <!-- 配置springmvc -->
23     <servlet>
24         <servlet-name>dispatcherServlet</servlet-name>
25         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
26         <init-param>
27             <param-name>contextConfigLocation</param-name>
28             <param-value>classpath:springmvc.xml</param-value>
29         </init-param>
30         <load-on-startup>1</load-on-startup>
31     </servlet>
32     <servlet-mapping>
33         <servlet-name>dispatcherServlet</servlet-name>
34         <url-pattern>/</url-pattern>
35     </servlet-mapping>
View Code
原文地址:https://www.cnblogs.com/step-and-step/p/9146781.html