In the development of java web, there will be a strange thing that the Chinese content will be garbled when it is written into the database. You can check and solve it according to the following points:
1. Check whether the utf-8 encoding format is set on the page.
2. Check the character set encoding format of the MySQL database.
Execute the statement after logging into the database SHOW VARIABLES LIKE 'character%';
Finally, it is safe to uniformly set it to utf-8
3. Set the encoding format in the java program.
Add the following code in the appropriate location:
request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
4. When creating a database, Navicate should ensure that the code is utf-8, as shown in the following figure:
5. Modify the specified code of the connection MySQL address.
Refer to the following modification:
jdbc: mysql://localhost:3306/ Database name? useUnicode=true&characterEncoding=utf-8