Workaround One:
MySQL installation when the code,
Look at the My.ini, there's no
[MySQL]
Default-character-set=utf8
[Client]
Default-character-set=utf8
[Mysqld]
Default-character-set=utf8 set up when creating a table:
DROP TABLE IF EXISTS ' Company ';
CREATE TABLE IF not EXISTS ' company '
(
' Cname ' VARCHAR not NULL,
' Caddr ' VARCHAR (100),
' Ctel ' VARCHAR (16)
) Engine=innodb DEFAULT Charset=utf8; JSP headers:
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8" if not, try:
Contenttype= "text/html;charset=gb2312" solution two:
When you connect to MySQL (regardless of whether you are reading or fetching data from MySQL), you specify that the encoding used is utf-8, as follows
Load MYSQL-JDBC Drive
Class.forName ("Com.mysql.jdbc.Driver"). newinstance ();
Connecting to a database
Connection Sqlcon = drivermanager.getconnection ("jdbc:mysql://localhost:3306/test?user=root&password=1& Useunicode=true&characterencoding=utf-8 "); Workaround Three:
If the method fails, then the read string is forced to be converted on the basis of method one.
String name = Request.getparameter ("name");
Name= New String (Name.getbytes ("iso-8859-1"), "Utf-8"); Or:
String name =new string (rst.getstring ("name"). GetBytes ("Iso-8859-1"), "Utf-8"); workaround four:
This method is the first in some articles, I also tried this method, but it seems not. Here is still to say, I do not know whether the operation is wrong. Let's stick to the original:
"Add a row to [mysqld] in profile C:winntmy.ini if you have Chinese in the database and the default language for MySQL is not Chinese":
Default-character-set=utf-8
And then start MySQL again.
Method Five: Change in the Web.xml under TOMCA or Web project:
<filter>
<filter-name>UTFEncoding</filter-name>
<filter-class>com.founder.chenph.util.encodingfilter_utf8
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UTFEncoding</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
&nbSp <filter-mapping>
<filter-name >UTFEncoding</filter-name>
< url-pattern>*.do</url-pattern>
</filter-mapping>