没改之前,中文乱码
httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
httpPost.setEntity(new StringEntity(JSONObject.toJSONString(putData)));
其实就是需要在将数据putDate转成StringEntity时,设置一个格式再发给httpPost
修改之后
httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
StringEntity stringEntity;
stringEntity = new StringEntity((JSONObject.toJSONString(putData)),"utf-8");
httpPost.setEntity(stringEntity);
参考了:https://blog.youkuaiyun.com/sdxushuxun/article/details/79282112 解决的问题
发篇文章免得日后自己忘记