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 NULL,
' caddr ' VARCHAR (MB),
' Ctel ' VARCHAR
) engine=innodb DEFAULT
JSP headers:
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>
If you can't, try:
Workaround 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
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");
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.ut Il. Encodingfilter_utf8 </filter-class> <init-param> <param-name>encodi ng</param-name> <param-value>UTF-8</param-value> </init-param> &L
T;/filter> <filter-mapping> <filter-name>UTFEncoding</filter-name>
<url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping>
<filter-name>UTFEncoding</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping>