调用rest-api接口时,返回的result是乱码
闻道阅读 发布于2016-09 浏览:1729 回复:1
0
收藏

这个如何解决?

我加了这段转码都不行。

private static String getUtf8String(String s) throws UnsupportedEncodingException
{
StringBuffer sb = new StringBuffer();
  sb.append(s);
  String xmlString = "";
  String xmlUtf8 = "";
  xmlString = new String(sb.toString().getBytes("GBK"));
  xmlUtf8 = URLEncoder.encode(xmlString , "GBK");

  return URLDecoder.decode(xmlUtf8, "UTF-8");
}


收藏
点赞
0
个赞
共1条回复 最后由用户已被禁言回复于2022-04
#2王继冬回复于2016-09

返回的json统一采用utf8编码方式

0
TOP
切换版块