转移服务器显示乱码,两台服务器之间数据传输乱码问题

服务器A 向 服务器B 传输数据,

服务器B接到数据:

两端都在方法里设置了:

request.setCharacterEncoding("UTF-8");

response.setContentType("text/plain; charset=UTF-8");

//开始获取:

String data = request.getParameter("json");

Log.info("发来数据:"+data);

String coding = getEncoding(data);

public static String getEncoding(String str) {

Log.info("--GB2312 :" + new String(str.getBytes(), "GB2312"));

Log.info("--ISO-8859-1 :" + new String(str.getBytes(), "ISO-8859-1"));

Log.info("--UTF-8 :" + new String(str.getBytes(), "UTF-8"));

Log.info("--GBK :" + new String(str.getBytes(), "GBK"));

Log.info("--GB2312 ---2:" + new String(str.getBytes("GB2312")));

Log.info("--ISO-8859-1 ---2:" + new String(str.getBytes("ISO-8859-1")));

Log.info("--UTF-8--2:" + new String(str.getBytes("UTF-8")));

Log.info("--GBK--2 :" + new String(str.getBytes("GBK")));

Log.info("UTF-8--GB2312 :" + new String(str.getBytes("UTF-8"), "GB2312"));

Log.info("UTF-8--ISO-8859-1 :" + new String(str.getBytes("UTF-8"), "ISO-8859-1"));

Log.info("UTF-8--UTF-8 :" + new String(str.getBytes("UTF-8"), "UTF-8"));

Log.info("UTF-8--GBK :" + new String(str.getBytes("UTF-8"), "GBK"));

Log.info("GB2312--UTF-8 :" + new String(str.getBytes("GB2312"), "UTF-8"));

Log.info("GB2312--ISO-8859-1 :" + new String(str.getBytes("GB2312"), "ISO-8859-1"));

Log.info("GB2312--GBK :" + new String(str.getBytes("GB2312"), "GBK"));

Log.info("GB2312--GB2312 :" + new String(str.getBytes("GB2312"), "GB2312"));

Log.info("ISO-8859-1--GBK :" + new String(str.getBytes("ISO-8859-1"), "GBK"));

Log.info("ISO-8859-1--UTF-8 :" + new String(str.getBytes("ISO-8859-1"), "UTF-8"));

Log.info("ISO-8859-1--GB2312 :" + new String(str.getBytes("ISO-8859-1"), "GB2312"));

Log.info("ISO-8859-1--ISO-8859-1 :" + new String(str.getBytes("ISO-8859-1"), "ISO-8859-1"));

Log.info("GBK--GB2312:" + new String(str.getBytes("GBK"), "GB2312"));

Log.info("GBK--ISO-8859-1:" + new String(str.getBytes("GBK"), "ISO-8859-1"));

Log.info("GBK--UTF-8:" + new String(str.getBytes("GBK"), "UTF-8"));

Log.info("GBK--GBK:" + new String(str.getBytes("GBK"), "GBK"));

}

日志截图里 xm:“???” 是中文名字,

无论怎么转换字符集,都是 ??? 格式乱码!

22bbffc17e2a1629054fa2728025839a.png

求大神帮忙看看!!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值