When jsp inserts mysql, the Chinese characters are garbled and the information for one morning is searched. The solution is recorded as follows: When jsp inserts data into mysql, the unified encoding is set on the jsp page first: request. setCharacterEncoding (UTF-8); then, when creating a database and a table, specify the unified encoding utf8, as follows: 1. When creating a database: CREATEDATABAS
When jsp inserts mysql, the Chinese characters are garbled and the information for one morning is searched. The solution is recorded as follows: When jsp inserts data into mysql, the unified encoding is set on the jsp page first: request. setCharacterEncoding (UTF-8); then, when creating a database and a table, specify the unified encoding utf8, as follows: 1. When creating a database: CREATE DATABAS
When jsp inserts mysql, the Chinese characters are garbled and the information for one morning is searched. The solution is recorded as follows:
When jsp inserts data into mysql, it first sets the unified encoding on the jsp page: request. setCharacterEncoding ("UTF-8 ");
Then, specify the unified encoding format utf8 during database creation and table creation. The format is as follows:
1. When creating a DATABASE: create database 'test'
Character set 'utf8'
COLLATE 'utf8 _ general_ci ';
2. create table 'database _ user '(
'Id' varchar (40) not null default '',
'Userid' varchar (40) not null default '',
) ENGINE = InnoDB default charset = utf8;
Modify the my. ini file in the default installation directory of mysql and change the default latain1 encoding format to UTF8.
When establishing a connection with mysql, change the url to the following format:
Url = jdbc: mysql: // localhost: 3306/database? UseUnicode = true & characterEncoding = UTF8
In this way, the connection method will be changed to the UTF8 format during connection.
In the command console, use show variables like 'Char % 'to view the current default connection mode.
Set character_set_server = 'utf8'; to modify the default connection mode.