jsp 页面用下面3句语句来保证是gbk 编码
<%@ halaman sesi="benar" %>
<%@ halaman contentType="teks/html;charset=gbk" %>
< %@halaman halamanEncoding="gbk"%>
<%request.setCharacterEncoding("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
#bahasa=D:/mysql/share/direktori bahasa Anda
#log permintaan lambat#=
#tmpdir#=
#pelabuhan=3306
#set-variable=key_buffer=16M
[WinMySQLadmin]
Server=D:/mysql/bin/mysqld-nt.exe
pengguna=michael
kata sandi=123
[klien]
default_character_set=gbk
读jsp页面之间传递的参数在页面显示正常
在dos命令行下插入数据后,显示也正常
其中一条插入语句如下:
<jsp:useBean id="reg" scope="page" class="test.chatreg" />
String strSQL="masukkan ke dalam chatreg(nama pengguna, kata sandi, email, beranda)
nilai('" + regName + "', '" + regPassword +"' , '" + regEmail + "' , '" + regHomepage + "') ";
reg.executeQuery(strSQL);