这个问题我遇见过,需要加一段代码,具体是什么我也不记得了,是一本很厚的JSP书上写的

解决方案 »

  1.   

    在request.getParameter()之前加一句
    request.setCharacterEncoding("gb2312");
    就好了~~~~
      

  2.   

    用转换函数处理request.getParameter("")
    <%
    String para = getChinese(request.getParameter("para"))
    %><%!
    public String getChinese(String str) {
        try{
          String temp_p=str;
          byte[] temp_t=temp_p.getBytes("ISO8859-1");
          String temp=new String(temp_t);
          return temp;
        }
        catch (Exception e){
          e.printStackTrace();
        }
        return "null";
    }
    %>
      

  3.   

    strTemp=new String(strTemp.getBytes("ISO8859-1"), "GB2312");
      

  4.   

    package com;
    import java.io.*;public class Chinacode
    {public  static String UnicodeToChinese(String s){
    try{
    if(s==null || s.equals(""))return "";
    String newstring=null;
    newstring= new String(s.getBytes("ISO8859_1"),"gb2312");
    return newstring;
    }
    catch(UnsupportedEncodingException e){
    return s;
    }
    }
    public static String ChineseToUnicode(String s){
    try{
    if(s==null || s.equals(""))return "";
    String newstring=null;
    newstring= new String(s.getBytes("gb2312"),"ISO8859_1");
    return newstring;
    }
    catch(UnsupportedEncodingException e){
    return s;
    }
    }
    }
      

  5.   

    /**
         * 将一个unicode字符串转换成GB2312中文字符串
         *
         * @param strUnicode unicode字符串
         * @return GB2312
         */
        static public String UnicodeToChinese(String strUnicode)
        {
            String strChinese = "";
            try {
                if ((strUnicode != null) && (strUnicode.length() > 0)) {
                    strChinese = new String(strUnicode.getBytes("ISO-8859-1"),
                                            "GB2312");
                }
            } catch (java.io.UnsupportedEncodingException e) {
                common.util.Log.print("Unicode to Chinese: " + e.getMessage());
                strChinese = "";
            }        return strChinese;
        }    /**
         * 将一个GB2312中文字符串转换成unicode字符串
         *
         * @param strChinese 中文字符串
         * @return ISO-8859-1
         */
        static public String ChineseToUnicode(String strChinese)
        {
            String strUnicode = "";
            try {
                if ((strChinese != null) && (strChinese.length() > 0)) {
                    strUnicode = new String(strChinese.getBytes("GB2312"),
                                            "ISO-8859-1");
                }
            } catch (java.io.UnsupportedEncodingException e) {
                common.util.Log.print("Chinese to Unicode: " + e.getMessage());
                strUnicode = "";
            }        return strUnicode;
        }
    jsp->数据库用ChineseToUnicode()方法转码,
    数据库->jsp用UnicodetoChinese()方法转码.
      

  6.   

    String value=request.getParameter("name");
    value=new String(value.getBytes("8859_1"));
      

  7.   

    需要经过转换String str  = request.getParameter("sssss");
    if(str!=null){
      str = new String(str.getBytes("8859_1");
    }
    else{
      str = "";
    }
      

  8.   

    at your database connection set encode to "gb2312"