1. The controller receives Chinese garbled characters
Reason: springmvc source code problem
solution: configure springmvc Chinese garbled filter
<!-- Spring字符集过滤器 建议放前面 不然拦截可能有问题-->
<filter>
<filter-name>SpringEncodingFilter</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>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SpringEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Note: If it does not take effect, check whether it is placed at the front of the filter. If the garbled characters cannot be solved, Move Kuangshen to completely solve the garbled characters
2. The controller returns Chinese garbled characters
Configuration in @RequestMapping
produces = {"text/plain;charset=utf-8"}