導航:首頁 > 編程語言 > 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實例相關的資料

熱點內容
php內存操作 瀏覽:6
1加手機號碼放哪個文件夾 瀏覽:728
大兵程序員 瀏覽:785
青桔app福利中心在哪裡 瀏覽:170
演算法安全是智能化戰爭的博弈焦點 瀏覽:497
編譯器用vs多少 瀏覽:316
pc單機游戲壓縮包下載 瀏覽:570
伺服器鎖定什麼意思 瀏覽:731
吐司解壓神器 瀏覽:70
程序員的電腦一般用什麼 瀏覽:934
如何從伺服器中查詢表是否存在 瀏覽:323
android首頁布局源碼 瀏覽:45
虎牙主播是怎麼安卓投屏的 瀏覽:782
redmonk編程語言排行榜 瀏覽:110
android嵌入html5 瀏覽:676
雲伺服器能永久使用嗎 瀏覽:904
linux安裝openresty 瀏覽:386
ubunt配置php 瀏覽:975
達達取貨碼在app哪裡 瀏覽:49
精靈寶可夢伺服器有什麼好玩的 瀏覽:261