请选择 进入手机版 | 继续访问电脑版

使用Java HttpComponent 组件访问接口后,返回的数据中,中文字符都显示为乱码了,我尝试在获取response数据的时候,转码成utf-8 编码,但是依然无效:
  1. CloseableHttpResponse response = httpClient.execute(httpGet);
  2.                 HttpEntity entity = response.getEntity();
  3.                 String body = EntityUtils.toString(entity, "UTF-8");
  4.                 System.out.println(body);
复制代码

显示结果:
  1. {"retCode":1,"retMsg":"Success","data":[{"secID":"000001.OFCN","ticker":"000001","secShortName":"??????","cnSpell":"HXCCHH","assetClass":"F","listStatusCD":"UN","transCurrCD":"CNY","partyID":26812},{"secID":"000001.XIBE","ticker":"000001","secShortName":"00??01","cnSpell":"00GZ01","exchangeCD":"XIBE","assetClass":"B","listStatusCD":"DE","listDate":"2000-03-07","transCurrCD":"CNY","ISIN":"CND0000000S5","partyID":11327},{"secID":"000001.XSHE","ticker":"000001","secShortName":"????","cnSpell":"PAYH","exchangeCD":"XSHE","assetClass":"E","listStatusCD":"L","listDate":"1991-04-03","transCurrCD":"CNY","ISIN":"CNE000000040","partyID":2},{"secID":"000001.ZICN","ticker":"000001","secShortName":"????","cnSpell":"SZZZ","exchangeCD":"XSHG","assetClass":"IDX","ISIN":"CNM000000019","partyID":17764},{"secID":"600000.XSHG","ticker":"600000","secShortName":"????","cnSpell":"PFYH","exchangeCD":"XSHG","assetClass":"E","listStatusCD":"L","listDate":"1999-11-10","transCurrCD":"CNY","ISIN":"CNE0000011B7","partyID":603}]}
复制代码


|

共2个回复 最后回复于 2015-7-8 10:29

发表于 2015-7-8 08:38:53 | 显示全部楼层
晕死,居然是因为project 默认编码是cp2132,eclipse的console默认输入时乱码而已,更改project编码为UTF-8之后,解救而此问题,真的好low的错误
发表于 2015-7-8 10:29:46 | 显示全部楼层
@cxli2,解决了就好~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

发新帖

精彩推荐

更多>
返回顶部 返回列表