刚刚遇到问题,不过现在已经解决,总结一个绝对可行方法。
我做的是一个调查问卷,里面有很多单选按纽组,为了显示方便。我把value设了中文。但跳转到显示结果的JSP页面时就 出现很多????,开始我以为用request.setCharacterEncoding("gb2312");就万事大吉,可是还是不行。这个??弄得我很头疼。翻了很多资料。发现通过request.getParameter返回的字符串永远都是8859_1,
看了很多也试了很多方法,最简单的是request.setCharacterEncoding("gb2312");<%@page contentType="text/html; charset=gb2312"%> 
但这个方法似乎对我很不管用,总显示????。
最后用了一个最原始的方法
public String toChinese(String strvalue) { 
try{ 
if(strvalue==null) 
return null; 
else 

strvalue = new String(strvalue.getBytes("8859_1"), "GB2312"); 
return strvalue; 

}catch(Exception e){ 
return null; 


这个方法行了。看来最原始的还是最好的。我觉得这个方法对于数据库或者表单提交都能解决。不信试试。错了请指正!

解决方案 »

  1.   

    请参考我的一个帖子
    比较详尽
    http://community.csdn.net/Expert/topic/4935/4935441.xml?temp=.3350489
    Good Luck :-)
      

  2.   

    request.setCharacterEncoding("gb2312");
    是设置post方法的,
    get方法要改
    sever.xml中的URIEncoding   <Connector
    port="80"               maxHttpHeaderSize="8192"
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   connectionTimeout="20000" disableUploadTimeout="true" 
       URIEncoding="UTF-8" />