/* 将 */ public static final Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1");
/* 改 */ public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
Use other packet capture tools to test whether your return result is UTF-8 Chinese. Problems often occur at the source or the last step. If the page is garbled, your JSP page does not set charset "UTF-8". If there are garbled characters in the browser console, use F12 Network and look at the response header Content-Type = text/html, Encoding and so on. There is no problem with these links. It is probably a problem with the String environment settings. The previous answers are worth your reference.
When using springmvc to return the json format in the project, the Chinese characters were garbled. I looked at the springmvc source code and found that the default encoding of the StringHttpMessageConverter class is ISO-8859-1 (tragedy, why does something as big as springmvc not use utf-8, I don’t understand)
Have you added CharacterEncodingFilter? If you haven’t added it, try adding it. If it doesn’t work: Which version of spirng and which version of tomcat are you using? And: It’s not as complicated as what’s said above. . . Looking at the pieces of xml is annoying. . .
It also depends on what encoding your web container is... It will be over if you just step on it.
Encoding support for spring-mvc encoding adapter. I remember correctly that the tag name is:
<mvc:message-converters>
goods
spring mvc adds Jackson support
Add spring mvc configuration
Or override StringHttpMessageConverter
Use other packet capture tools to test whether your return result is UTF-8 Chinese.
Problems often occur at the source or the last step.
If the page is garbled, your JSP page does not set charset "UTF-8".
If there are garbled characters in the browser console, use F12 Network and look at the response header Content-Type = text/html, Encoding and so on.
There is no problem with these links. It is probably a problem with the String environment settings. The previous answers are worth your reference.
When using springmvc to return the json format in the project, the Chinese characters were garbled. I looked at the springmvc source code and found that the default encoding of the StringHttpMessageConverter class is ISO-8859-1 (tragedy, why does something as big as springmvc not use utf-8, I don’t understand)
Here is the solution,
springmvc configuration file:
To use this configuration, delete the in springmvc and do not use the default initialization configuration of springmvc
Have you added CharacterEncodingFilter? If you haven’t added it, try adding it. If it doesn’t work:
Which version of spirng and which version of tomcat are you using?
And:
It’s not as complicated as what’s said above. . . Looking at the pieces of xml is annoying. . .