jsp插入mysql数据库后乱码的处理办法
jsp 页面用下面3句语句来保证是gbk 编码
数据库衔接用如下语句
String sConnStr ="jdbc:mysql://localhost:3306/test?user=michael&password=123456&useUnicode=true&characterEncoding=gbk" ;
并且在mysql的my.ini的内容如下
basedir=D:/mysql
#bind-address=127.0.0.1
datadir=D:/mysql-data/data
default_character_set=gbk
#language=D:/mysql/share/your language directory
#slow query log#=
#tmpdir#=
#port=3306
#set-variable=key_buffer=16M
[WinMySQLadmin]
Server=D:/mysql/bin/mysqld-nt.exe
user=michael
password=123
[client]
default_character_set=gbk
读jsp页面之间传递的参数在页面显示失常
在dos命令行下插入数据后,显示也失常
其中一条插入语句如下:
String strSQL="insert into chatreg(username , password , email ,homepage )
values('" + regName + "', '" + regPassword +"' , '" + regEmail + "' , '" + regHomepage + "') ";
reg.executeQuery(strSQL);