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页面显示过程中不需要进行字符集转换,中文都可正常显示。
本人亲自测试!