导航:首页 > 编程语言 > 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实例相关的资料

热点内容
高新区编程加盟找哪家 浏览:22
服务器什么样的好卖 浏览:140
单片机原理及应用第二版例题答案 浏览:960
base64encoderjava 浏览:482
linux视频转换 浏览:694
linux与unixshell编程指南 浏览:133
vb6反编译程序错误 浏览:121
服务器弄挂有什么影响 浏览:302
安卓软件为什么运行不了 浏览:526
什么安卓手机是四方的 浏览:477
云服务器厂商租用多少钱 浏览:353
平安车贷解压要多久 浏览:416
乐一php程序员待遇 浏览:164
ZDM命令无法识别 浏览:922
解压小手工A4纸 浏览:983
钢筋加密区是几倍 浏览:671
编译程序代码软件 浏览:808
怎么恢复加密的东西 浏览:989
程序员卖茶 浏览:700
后端程序员英文 浏览:365