首页 > 其他 > 详细

RequestBody 和RequestEntity使用

时间:2019-10-30 00:29:25      阅读:1400      评论:0      收藏:0      [点我收藏+]
1 HttpClient client = new HttpClient();
2 PostMethod post = new PostMethod(redirectUrl);
3         Part[] parts = {
4                 new StringPart("user", “aaa”),
5                 new StringPart("password", "bbb")
6                 };
7         post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
8 client.executeMethod(post);
9 String result = post.getResponseBodyAsString();
1 HttpClient client = new HttpClient();
2 PostMethod post = new PostMethod(redirectUrl);
3         NameValuePair[] pairs = {
4             new NameValuePair("user", “aaa”),
5                         new NameValuePair("password", “bbb”)
6                         };
7         post.setRequestBody(pairs);
8 client.executeMethod(post);
9 String result = post.getResponseBodyAsString();

 

RequestBody 和RequestEntity使用

原文:https://www.cnblogs.com/leavescy/p/11761864.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!