byte[] b;
String msg = request.getParameter("mesg");
         
 if(msg!=null&&msg!=""){
   b=msg.getBytes("UTF-8");
String address=new String(b,"GBK");
System.out.println("address="+address);//乱码 }

解决方案 »

  1.   

    这里改成b=msg.getBytes("UTF-8");b=msg.getBytes("gb2312");
    试试。参照   String b=(String)request.getAttribute("c");  
        String a=new String(b.getBytes("iso885901"),"gbk");
      

  2.   

    楼上的正解 但是要改下
    String a=new String(b.getBytes("iso-8859-1"),"gbk");
      

  3.   


    着急打错了 呵呵参照   String b=(String)request.getAttribute("c");  
        String a=new String(b.getBytes("iso8859-1"),"gbk");
      

  4.   

    import java.io.UnsupportedEncodingException;/**
     * 字符转化类转化工具
     * 
     * @author cooole
     * 
     */
    public class CharFormatUtil {
    /**
     * 将str由fromCode 转化为toCode
     * @param str
     * @param fromCode
     * @param toCode
     * @return
     * @throws UnsupportedEncodingException
     */
    public static String format(String str, String fromCode, String toCode)
    throws UnsupportedEncodingException {
    if (str != null) {
    return new String(str.getBytes(fromCode), toCode);
    } else {
    return null;
    }
    } public static String formatLatin2UTF8(String str)
    throws UnsupportedEncodingException {
    return format(str, "ISO8859-1", "UTF-8");
    } public static String formatLatin2GBK(String str)
    throws UnsupportedEncodingException {
    return format(str, "ISO8859-1", "GBK"); }
    }