Java Web project, the foreground page of the form data, inserted into the database, the results appear garbled "???" The problem of intermittent tossing for a day time, nonsense not to say, steps are as follows:
One: Configuration in Web. XML: Encoded format Interceptor
<!--code format blocker-- <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>
This ensures that the data passed to the controller is not garbled, and if it is garbled, it should be considered at the database level.
Second: Check the configuration of the database:1. Make sure that the UTF8 is set in the connection URL of the database:
Url:jdbc:mysql://localhost:3306/blog-qwc?useunicode=true&characterencoding=utf-8& Zerodatetimebehavior=converttonull&allowmultiqueries=true
2. Ensure that the database you are creating is configured to support Chinese,
Database Properties Support: UTF8--UTF-8 Unicode
Database collation: Utf8_general_ci
3. Modify the encoding of the table blog under the database connection:
ALTER TABLE blog default character set UTF8;
4. Modify the encoding of each field in a table blog:
Change the character set for each column in the table to Utf-8
ALTER TABLE blog change title title varchar (set UTF8; ALTER TABLE Blog Change author author varchar (set UTF8; ALTER TABLE BLOG Change MD MD varchar (set UTF8; ALTER TABLE blog change HTML HTML varchar (set UTF8;
NOTE: ALTER TABLE blog change HTML HTML varchar ($) Character set UTF8; field HTML to write two times, no problem
5. If the problem is not resolved, the problem should be the URL of the database connection itself:
To modify a URL in a db.properties file:
Url:jdbc:mysql://localhost:3306/blog-qwc?useunicode=true&characterencoding=utf-8; Zerodatetimebehavior=converttonull;allowmultiqueries=true
Modified to:
Url:jdbc:mysql://localhost:3306/blog-qwc?useunicode=true&characterencoding=utf-8& Zerodatetimebehavior=converttonull&allowmultiqueries=true
Modified content: & = = "&
6. If it doesn't work, delete the database connection and try again
That's the way it is.
Springmvc+mybatis+mysql Database Insert Chinese is garbled