springmvc 请求出现乱码,配置过滤器后还是出现乱码

tech2022-08-13  133

@RequestMapping("/quick8") @ResponseBody public void sace8(Vo vo){ System.out.println("乱码"); System.out.println(vo); }

配置全局filter

<!--配置全局过滤filter--> <filter> <filter-name>CharacterEncodingFilter</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>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

如果还未解决检查tomcat版本 如果是tomcat7,tomcat7编码模式是iso-8859-1 springmvc是utf-8 所以会出现乱码 换成tomcat8后解决问题

maven配置本地tomcat8

配置本地tomcat8后问题解决

最新回复(0)