我将一个file中的json字符串取出,实例化一个StringEntiry,将json字符串写入请求体中。然后无论我以哪种编码方式输出StringEntity中的content,其中的中文均为乱码“???”。 这是怎么回事?
entity = new StringEntity(data,"UTF-8");
StringEntity stringEntity = new StringEntity(sendData,"UTF-8");
stringEntity.setContentType("application/json");
其实说这么多 ,解决问题的关键就一句话,在new StringEntity()的时候指定编码就解决了,因为在new的同时已经做了字符串的转码操作