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

热点内容
数据库查询系统源码 浏览:611
php5314 浏览:350
完美国际安装到哪个文件夹 浏览:663
什么app可以扫一扫做题 浏览:534
程序员编码论坛 浏览:918
淘点是什么app 浏览:654
中国高等植物pdf 浏览:447
51单片机时间 浏览:176
后台如何获取服务器ip 浏览:260
单片机流水灯程序c语言 浏览:227
程序员第二职业挣钱 浏览:234
运行里怎么输入服务器路径 浏览:833
pythonstepwise 浏览:502
刘一男词汇速记指南pdf 浏览:56
php认证级别 浏览:361
方舟编译啥时候推送 浏览:1003
php手机验证码生成 浏览:669
哲学思维pdf 浏览:9
凌达压缩机有限公司招聘 浏览:527
weblogic命令部署 浏览:30