大家好:
我在jsp页面接受参数 然后到数据库里进行相应的查询.在jbuilder 里一切正常,但当我打包发布到web服务器下就有问题了.当我选择按城市查询时,比如北京,可以找到很多条符合的数据,会有分页.然后显示在jsp页面中,但当我点击下一页的时候,'北京'这个参数就边成了乱码了.这里我打印了输出语句:
当显示第一页时
sqlStr==select top 50 User_id,Name,Eid,Gender,Hire_day,Hbmonth,Hbday,Job_function,Location,Reporting_manager,Bu from t_user where 1=1 and Gender ='F' and Location ='北京' order by User_id当点击下一页时
sqlStr==select top 50 User_id,Name,Eid,Gender,Hire_day,Hbmonth,Hbday,Job_function,Location,Reporting_manager,Bu from t_user where 1=1 and Gender ='F' and Location ='±±??' order by User_id这个是第二页网页传递的参数:
http://127.0.0.1:8080/datacenter/index1.jsp?page=2&Gender=F&Byear=&Bmonth=&Bday=&Hire_day=&Location=北京&Reporting_manager=&Host_manager=&Bu=看起来都没问题,,可是在第二页'北京'为什么是乱码呢?
我已经在接受参数的语句中 写了request.setCharacterEncoding("GB2312");这句话,,真不知道问题出在哪里了.
我的环境是 sql2000+tomcat请各位帮帮忙啊,, 老板就要review了..谢谢大家
我在jsp页面接受参数 然后到数据库里进行相应的查询.在jbuilder 里一切正常,但当我打包发布到web服务器下就有问题了.当我选择按城市查询时,比如北京,可以找到很多条符合的数据,会有分页.然后显示在jsp页面中,但当我点击下一页的时候,'北京'这个参数就边成了乱码了.这里我打印了输出语句:
当显示第一页时
sqlStr==select top 50 User_id,Name,Eid,Gender,Hire_day,Hbmonth,Hbday,Job_function,Location,Reporting_manager,Bu from t_user where 1=1 and Gender ='F' and Location ='北京' order by User_id当点击下一页时
sqlStr==select top 50 User_id,Name,Eid,Gender,Hire_day,Hbmonth,Hbday,Job_function,Location,Reporting_manager,Bu from t_user where 1=1 and Gender ='F' and Location ='±±??' order by User_id这个是第二页网页传递的参数:
http://127.0.0.1:8080/datacenter/index1.jsp?page=2&Gender=F&Byear=&Bmonth=&Bday=&Hire_day=&Location=北京&Reporting_manager=&Host_manager=&Bu=看起来都没问题,,可是在第二页'北京'为什么是乱码呢?
我已经在接受参数的语句中 写了request.setCharacterEncoding("GB2312");这句话,,真不知道问题出在哪里了.
我的环境是 sql2000+tomcat请各位帮帮忙啊,, 老板就要review了..谢谢大家
当点击下一页时
sqlStr==select top 0User_id,Name,Eid,Gender,Hire_day,Hbmonth,Hbday,Job_function,Location,Reporting_manager,Bu from t_user where 1=1 and Gender ='F' and Location ='±±??' order by User_id
页面使用UTF-8编码;
页面另存为UTF-8格式(以记事本为例:在“另存为”时选择“编码”为UTF-8)
在IE浏览器的"工具-->Internet选项-->高级 --> (拉到最下面)勾选“总是以UTF-8发送URL”,默认是已经勾选的。
http://127.0.0.1:8080/datacenter/index1.jsp?page=2&Gender=F&Byear=&Bmonth=&Bday=&Hire_day=&Location=北京&Reporting_manager=&Host_manager=&Bu=
传,HTML的一些窗口只要知道name=searchField就可以在跳转的页面上使用
String searchfield=request.getParameter("searchField"))获取,这样避免传参的乱码啦!如果还会出现乱码可能需要进一步编写bean代码去转换.一般就是gbk(gb2312) to ISO8859-1和ISO-8859-1 TO gbk(gb2312).
request.setEncoding("gb2312")