在web.xml添加如下代码
<!-- 配置过滤器(解决数据请求乱码)-->
<filter>
<filter-name>CharacterEncodingFilterer</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilterer</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>