大家好:
我在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了..谢谢大家

解决方案 »

  1.   

    哦,点击下一也的sql语句是:
    当点击下一页时
    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
      

  2.   

    一般都是尽量避免使用URL的形式传递中文的。解决方式(不一定有效):
      页面使用UTF-8编码;
      页面另存为UTF-8格式(以记事本为例:在“另存为”时选择“编码”为UTF-8)
      在IE浏览器的"工具-->Internet选项-->高级 --> (拉到最下面)勾选“总是以UTF-8发送URL”,默认是已经勾选的。
      

  3.   

    不一定非要
    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).
      

  4.   

    建议把接受参数时编码用gb2312,应该没有问题的,我都是用这个编码方式
    request.setEncoding("gb2312")
      

  5.   

    哦,多谢大家了,我刚才又试了好多方法,还是不成,,可是在jbuilder里就没问题。真不知道问题出在哪里了,难道和tomcat5.0的版本有关吗 ?