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

热点内容
sql数据库查询表命令 浏览:551
简单音乐网站源码 浏览:644
运动健康app华为手表怎么连接 浏览:748
肌肉塑造全书pdf下载 浏览:796
安卓简约拼图用什么软件好 浏览:289
fx1n加密程序 浏览:844
淘客阿里云服务器 浏览:476
100压缩打造 浏览:422
安卓手机怎么和苹果平板传文件 浏览:973
开始选项卡中的页眉和页脚命令选项 浏览:424
pdf的字体怎么改 浏览:856
python读写视频 浏览:88
科鲁兹压缩机轴承 浏览:353
word文档转换成pdf文件找不到 浏览:27
组件注册命令 浏览:760
安卓大屏导航用的是什么运放 浏览:443
myandroidtools的备份 浏览:900
python爬虫天气预报 浏览:761
android70权限管理 浏览:749
魔兽辛迪加是什么服务器 浏览:472