a.jsp?a=长春&b=朝阳区String a = ServletActionContext.getRequest().getParameter("a");
String b = ServletActionContext.getRequest().getParameter("b");String cc = new String(a.getBytes("iso-8859-1"),"UTF-8");
String cyq = new String(b.getBytes("iso-8859-1"),"UTF-8");输出 cc 正常能得到长春   输出 cyq 得到的是 朝阳?我是新手  刚刚上班 有很多地方不会 请高手指教!!!

解决方案 »

  1.   

    请在tomcat的server.xml文件中给你的Connector添加URIEncoding参数  例如:<Connector port="8080" protocol="HTTP/1.1" 
                   connectionTimeout="20000" 
                   redirectPort="8443" 
       URIEncoding="UTF-8" useBodyEncodingForURI="true"/>
      

  2.   

    试试这个  应该没问题String cc = new String(a.getBytes("GBK"), "GBK");
    String cyq = new String(b.getBytes("GBK"), "GBK");
      

  3.   


    String cc = new String(a.getBytes("ISO-8859-1"), "GB2312");
    String cyq = new String(b.getBytes("ISO-8859-1"), "GB2312");
      

  4.   

    在你的jsp页上encode下http://topic.csdn.net/t/20010704/20/181836.html
      

  5.   

    http://blog.sina.com.cn/s/blog_4ab5cd7d0100exz7.html
      

  6.   

    String a = new String(request.getParameter("a").getBytes("ISO-8859-1"),"UTF-8"); 
    String b= new String(request.getParameter("b").getBytes("ISO-8859-1"),"UTF-8");