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

熱點內容
杭州it程序員對身體好不好 瀏覽:533
高新區編程加盟找哪家 瀏覽:22
伺服器什麼樣的好賣 瀏覽:140
單片機原理及應用第二版例題答案 瀏覽:960
base64encoderjava 瀏覽:482
linux視頻轉換 瀏覽:696
linux與unixshell編程指南 瀏覽:133
vb6反編譯程序錯誤 瀏覽:121
伺服器弄掛有什麼影響 瀏覽:302
安卓軟體為什麼運行不了 瀏覽:526
什麼安卓手機是四方的 瀏覽:477
雲伺服器廠商租用多少錢 瀏覽:353
平安車貸解壓要多久 瀏覽:416
樂一php程序員待遇 瀏覽:164
ZDM命令無法識別 瀏覽:922
解壓小手工A4紙 瀏覽:983
鋼筋加密區是幾倍 瀏覽:671
編譯程序代碼軟體 瀏覽:808
怎麼恢復加密的東西 瀏覽:989
程序員賣茶 瀏覽:700