Troubleshooting reasons:
Break point, to see whether it is in the execution of the database operation before the garbled, or after the database operation is garbled.
Solutions for the former:
In Web. XML, add:
<Filter> <Filter-name>Encodingfilter</Filter-name> <Filter-class>Org.springframework.web.filter.CharacterEncodingFilter</Filter-class> <async-supported>True</async-supported> <Init-param:> <Param-name>Encoding</Param-name> <Param-value>UTF-8</Param-value> </Init-param></Filter><filter-mapping> <Filter-name>Encodingfilter</Filter-name> <Url-pattern>/*</Url-pattern></filter-mapping>
When configuring the JDBC data source, add:
Jdbc:mysql://127.0.0.1:3306/logistics?useunicode=true&characterencoding=utf-8
Storage database operation garbled, solution:
Log in to the database and execute the following sql:
Show variables like ' character% ';
Results:
| character_set_client | UTF8 |
| character_set_connection | UTF8 |
| Character_set_database | Latin1 |
| Character_set_filesystem | binary |
| Character_set_results | UTF8 |
| Character_set_server | Latin1 |
| character_set_system | UTF8 |
Indicates that the Character_set_database,character_set_server encoding format was incorrect when installing the database.
Solve:
Locate the my.cnf file under the MySQL installation path and add the following two lines under [mysqld]:
Character_set_server=utf8
init_connect= ' SET NAMES UTF8 '
Check again for problem resolution:
| character_set_client | UTF8 |
| character_set_connection | UTF8 |
| Character_set_database | UTF8 |
| Character_set_filesystem | binary |
| Character_set_results | UTF8 |
| Character_set_server | UTF8 |
| Character_set_system | Utf8
Web project storage data to database, Chinese garbled, resolution process