-
To modify the html/jsp page encoding format:
<meta charset= "UTF-8" > or <%@ page contenttype= "text/html; charset=utf-8"%>
-
encoding settings in Web. XML ( you need to set the Forceencoding parameter value to true to force the target encoding to encoded format )
<filter>
<filter-name>CharacterEncoding</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>CharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
However, this setting is for post requests, Tomacat for Get and post requests are handled differently, to handle encoding problems for GET requests, you need to change the Server.xml configuration file for Tomcat, as follows:
3.Tomcat's server.xml configuration file
<connector connectiontimeout= "20000" port= "8080" protocol= "http/1.1" redirectport= "8443"/>
4. Database garbled
Configure the data source encoding format
< Property name="url"
value="Jdbc:mysql://121.40.90.125/test?" useunicode=true&characterencoding=utf-8"></ Property>
Then go to modify the database, the table in the encoding format of the column UTF8
Let MySQL support emoji emoticons
Solution: Convert the MySQL encoding from UTF8 to UTF8MB4.
To modify the database character set:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
To modify the character set of a table:
ALTER TABLE table_name CONVERT to CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
To modify the character set of a field:
ALTER TABLE table_name Change column_name column_name VARCHAR (191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Garbled solution in Spring,web,java development