1 <!DOCTYPE web-app PUBLIC 2 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 3 "http://java.sun.com/dtd/web-app_2_3.dtd" > 4 5 <web-app> 6 <context-param> 7 <param-name>contextConfigLocation</param-name> 8 <param-value>classpath:applicationContext.xml</param-value> 9 </context-param> 10 <!-- 设置字符编码,将所有的字符编码同意设置为utf-8 --> 11 <filter> 12 <filter-name>filterEncoding</filter-name> 13 <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 14 <init-param> 15 <param-name>encoding</param-name> 16 <param-value>UTF-8</param-value> 17 </init-param> 18 <init-param> 19 <param-name>forceEncoding</param-name> 20 <param-value>true</param-value> 21 </init-param> 22 </filter> 23 <filter-mapping> 24 <filter-name>filterEncoding</filter-name> 25 <url-pattern>/*</url-pattern> 26 </filter-mapping> 27 <listener> 28 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 29 </listener> 30 <!-- 配置requestcontext监听器 --> 31 <listener> 32 <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> 33 </listener> 34 <servlet> 35 <servlet-name>springmvc</servlet-name> 36 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 37 <init-param> 38 <param-name>contextConfigLocation</param-name> 39 <param-value>classpath:springmvc.xml</param-value> 40 </init-param> 41 </servlet> 42 <servlet-mapping> 43 <servlet-name>springmvc</servlet-name> 44 <url-pattern>*.do</url-pattern> 45 </servlet-mapping> 46 </web-app>