httpclient4 post提交请求乱码问题解决

分享一下我老师大神的人工智能教程吧。零基础,通俗易懂!风趣幽默!http://www.captainbed.net/

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

第一种:

HttpPost post=new HttpPost(url);

StringEntity content=new StringEntity(data, Charset.forName("utf-8"));// 设置编码

content.setContentType("application/json; charset=UTF-8");

content.setContentEncoding("utf-8");

post.setEntity(content);

第二种:

httpPost.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));//在设置请求数据的时候,指定编码。

           

给我老师的人工智能教程打call!http://www.captainbed.net/

这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_43717814/article/details/84293510