导航:首页 > 编程语言 > javarest实例

javarest实例

发布时间:2023-07-25 03:40:30

java调用rest接口如何HttpClient 使用put x-www-form-urlencoded数据

把post的改成put试试
HttpPost httpPost = new HttpPost("http xxx");
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("username", "vip"));
nvps.add(new BasicNameValuePair("password", "secret"));
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
CloseableHttpResponse response2 = httpclient.execute(httpPost);

try {
System.out.println(response2.getStatusLine());
HttpEntity entity2 = response2.getEntity();
// do something useful with the response body
// and ensure it is fully consumed
EntityUtils.consume(entity2);
} finally {
response2.close();
}

阅读全文

与javarest实例相关的资料

热点内容
怎么对hex文件进行加密 浏览:281
pdf少年时 浏览:950
两个同名文件夹同步 浏览:627
拍照文件夹哪个好用 浏览:86
文件夹和书包 浏览:507
解压归档拿登记证 浏览:220
去体验解压房 浏览:610
单片机一键中断响应 浏览:643
唐浩明pdf 浏览:841
程序员土木 浏览:71
android如何与web服务器交互 浏览:606
苹果小风扇app怎么下 浏览:954
杭州it程序员对身体好不好 浏览:534
高新区编程加盟找哪家 浏览:30
服务器什么样的好卖 浏览:149
单片机原理及应用第二版例题答案 浏览:969
base64encoderjava 浏览:491
linux视频转换 浏览:703
linux与unixshell编程指南 浏览:140
vb6反编译程序错误 浏览:128