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

熱點內容
javacdataxml 瀏覽:943
本機tcp伺服器地址 瀏覽:426
切換pdf 瀏覽:92
iturns下載的app在哪裡 瀏覽:639
雲起書院App在哪裡 瀏覽:614
怎麼對hex文件進行加密 瀏覽:285
pdf少年時 瀏覽:953
兩個同名文件夾同步 瀏覽:630
拍照文件夾哪個好用 瀏覽:91
文件夾和書包 瀏覽:511
解壓歸檔拿登記證 瀏覽:225
去體驗解壓房 瀏覽:613
單片機一鍵中斷響應 瀏覽:646
唐浩明pdf 瀏覽:845
程序員土木 瀏覽:73
android如何與web伺服器交互 瀏覽:611
蘋果小風扇app怎麼下 瀏覽:958
杭州it程序員對身體好不好 瀏覽:537
高新區編程加盟找哪家 瀏覽:33
伺服器什麼樣的好賣 瀏覽:152