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

热点内容
哪个读书app可以真实领到钱 浏览:887
javaclasspath环境变量 浏览:843
android内置sd外置sd卡 浏览:630
程序员在东南亚被毒打 浏览:284
php内存操作 浏览:6
1加手机号码放哪个文件夹 浏览:728
大兵程序员 浏览:785
青桔app福利中心在哪里 浏览:170
算法安全是智能化战争的博弈焦点 浏览:497
编译器用vs多少 浏览:316
pc单机游戏压缩包下载 浏览:570
服务器锁定什么意思 浏览:731
吐司解压神器 浏览:70
程序员的电脑一般用什么 浏览:934
如何从服务器中查询表是否存在 浏览:323
android首页布局源码 浏览:46
虎牙主播是怎么安卓投屏的 浏览:782
redmonk编程语言排行榜 浏览:110
android嵌入html5 浏览:676
云服务器能永久使用吗 浏览:904