页面开始使用<%@ page contentType="text/html; charset=GB2312" %>只对当前页面的中文内码有用。接收参数时还是要用字符转换的String inputinfo = new String(request.getParameter("nodeinfo").getBytes("8859_1"),"GB2312");

解决方案 »

  1.   

    做个处理
      public String toChinese(String ss) {
        if(ss!=null){
          //处理中文问题
          try{
            String temp_p=ss;
            byte[] temp_t=temp_p.getBytes("ISO8859-1");
            ss=new String(temp_t);
          }catch(Exception e){
            System.err.println("toChinese exception:"+e.getMessage());
            System.err.println("The String is:"+ss);
          }
        }
        return ss;
      }
      

  2.   

    在request.getParameter()这个页面加上
    request.setCharacterEncoding("GB2312");
      

  3.   

    String aaa= new String(request.getParameter("nodeinfo").getBytes("8859_1"),"GB2312");
    需要将中文转化为西文码
      

  4.   

    请问
    1、request.setCharacterEncoding("GB2312");具体该怎样加,我直接加到JSP页面的<% %>中,提示错误。
    2、String aaa= new String(request.getParameter("nodeinfo").getBytes("8859_1"),"GB2312");中的nodeinfo是指任意的字符吗?
    3、是否出现过的中文都需要进行转换?
      

  5.   

    1、在Servlet的doPost()中加入
            request.setCharacterEncoding("GB2312");
            response.setContentType("text/html; charset=GB2312");2、是你的域
      

  6.   

    页面开始使用<%@ page contentType="text/html; charset=GB2312" %>只对当前页面的中文内码有用。接收参数时还是要用字符转换的String inputinfo = new String(request.getParameter("nodeinfo").getBytes("8859_1"),"GB2312");就可以了啊其中nodeinfo是你传到这个网页的参数啊