1. <?xml version="1.0" encoding="UTF-8"?>  

  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">  

  3.   <display-name>springMVC1</display-name>  

  4.   <welcome-file-list>  

  5.     <welcome-file>index.html</welcome-file>  

  6.   </welcome-file-list>  

  7.     

  8.   <servlet>  

  9.      <servlet-name>springMVC</servlet-name>  

  10.      <!-- springMVC的分发器 -->  

  11.      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  

  12.      <init-param>  

  13.         <param-name>contextConfigLocation</param-name>  

  14.         <param-value>classpath*:config/springAnnotation-servlet.xml</param-value>  

  15.      </init-param>  

  16.      <!-- 表示当Tomcat已启动的时候初始化这个Servlet -->  

  17.      <load-on-startup>1</load-on-startup>  

  18.   </servlet>  

  19.     

  20.   <filter>    

  21.       <filter-name>encodingFilter</filter-name>    

  22.       <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>    

  23.       <init-param>    

  24.           <param-name>encoding</param-name>    

  25.           <param-value>UTF-8</param-value> <!--设置你想用的字符集,我这里用的是GB18030-->    

  26.       </init-param>    

  27.       <init-param>  

  28.         <param-name>forceEncoding</param-name>  

  29.         <param-value>true</param-value>  

  30.       </init-param>  

  31.   </filter>    

  32.       

  33.   <filter-mapping>    

  34.       <filter-name>encodingFilter</filter-name>    

  35.       <url-pattern>/*</url-pattern> <!--设置你想过滤的页面或者是Servlet,根据自己的需要配置-->    

  36.  </filter-mapping>    

  37.    

  38.   <servlet-mapping>  

  39.     <servlet-name>springMVC</servlet-name>  

  40.     <url-pattern>/</url-pattern>  

  41.   </servlet-mapping>  

  42. </web-app>