1.設置my.ini中兩處default-character-set=latin1改爲:default-character-set=gbk
2.建表時指定utf-8字符集,如:
create table hluser(
userid char(20) not null,
username char(20) not null,
userpwd char(50) not null,
primary key(userid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
3.jsp中:
<%@ page session="true" contentType="text/html;charset=GB2312"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
這樣,數據庫插入的中文不會是亂碼;jsp頁面顯示過程中不需要進行字符集轉換,中文都可正常顯示。
本人親自測試!