2。请问在此jsp中
 request.setCharacterEncoding("GBK") ;是这样设吗?这句话详细意义是什么?
把请求字符串中的代码格式转换为GBK

解决方案 »

  1.   

    我前几天也碰到这个问题了。看看这个 
    package project;import java.io.*;public class TransFormat{
    public static String UnicodeToGB(String strln){
    byte[]b;
    String strOut=null;
    if(strln==null||(strln.trim()).equals(""))
    return strln;
    try{
    strOut=new String(strln.getBytes("ISO-8859-1"),"gb2312");
    }catch(UnsupportedEncodingException e){}
    return strOut;
    }

    public static String GBToUnicode(String strln){
    String strOut=null;
    if(strln==null||(strln.trim()).equals(""))
    return strln;
    try{
    byte[] b=strln.getBytes("ISO8859_1");
    strOut=new String(b,"GBK");
    }catch(Exception e){}
    return strOut;
    }
    }