jsp 页面用下面3句语句来保证是gbk 编码
<%@ page session="true" %>
<%@ page contenttype="text/html;charset=gbk" %>
<%@page pageencoding="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
#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命令行下插入数据后,显示也正常
其中一条插入语句如下:
<jsp:usebean id="reg" scope="page" class="test.chatreg" />
string strsql="insert into chatreg(username , password , email ,homepage )
values('" + regname + "', '" + regpassword +"' , '" + regemail + "' , '" + reghomepage + "') ";
reg.executequery(strsql);
新闻热点
疑难解答