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

熱點內容
瀕湖脈學白話解pdf 瀏覽:280
python進度條時間控制 瀏覽:640
javascript實例pdf下載 瀏覽:900
飯角app下載的文件在手機哪裡 瀏覽:829
金碟k3伺服器端需要配置ip地址 瀏覽:37
程序員是如何度過一天的 瀏覽:987
中央傳命令 瀏覽:565
cad畫戶型圖修剪命令 瀏覽:211
代碼編譯伺服器配置 瀏覽:208
河南租伺服器帶寬怎麼確定雲主機 瀏覽:177
python公式報告 瀏覽:133
阿里雲伺服器換手機 瀏覽:714
linux標准教程pdf 瀏覽:968
騰訊雲在哪找伺服器 瀏覽:682
單片機專家app漢化版 瀏覽:397
pdf列印內存不足 瀏覽:845
單片機連通虛擬機檢測網址指令 瀏覽:310
韓國伺服器怎麼選 瀏覽:282
光敏感測器嵌入單片機 瀏覽:413
php實現多繼承 瀏覽:679