第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

defaultHttpClient 過(guò)時(shí)處理

defaultHttpClient 警告過(guò)時(shí),有什么可以替代的嗎

正在回答

3 回答

DefaultHttpClient 用 CloseableHttpClient

HttpResponse 用 CloseableHttpResponse

官方新api的樣例

Get方法:

????CloseableHttpClient?httpclient?=?HttpClients.createDefault();
????HttpGet?httpGet?=?new?HttpGet("http://targethost/homepage");
????CloseableHttpResponse?response1?=?httpclient.execute(httpGet);
????//?The?underlying?HTTP?connection?is?still?held?by?the?response?object
????//?to?allow?the?response?content?to?be?streamed?directly?from?the?network?socket.
????//?In?order?to?ensure?correct?deallocation?of?system?resources
????//?the?user?MUST?either?fully?consume?the?response?content??or?abort?request
????//?execution?by?calling?CloseableHttpResponse#close().

????try?{
????????System.out.println(response1.getStatusLine());
????????HttpEntity?entity1?=?response1.getEntity();
????????//?do?something?useful?with?the?response?body
????????//?and?ensure?it?is?fully?consumed
????????EntityUtils.consume(entity1);
????}?finally?{
????????response1.close();
????}


Post方法:

??????HttpPost?httpPost?=?new?HttpPost("http://targethost/login");
????//拼接參數(shù)
????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
????????//消耗掉response
????????EntityUtils.consume(entity2);
????}?finally?{
????????response2.close();
????}


1 回復(fù) 有任何疑惑可以回復(fù)我~

導(dǎo)入httpclient 4.2.5

導(dǎo)入httpcore 4.2.4

我跟你遇到過(guò)同樣的問(wèn)題,親測(cè)有效

1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

qq_酷愛(ài)達(dá)人_0

傻?。?!
2017-06-13 回復(fù) 有任何疑惑可以回復(fù)我~
#2

漂泊流浪的懶漢 回復(fù) qq_酷愛(ài)達(dá)人_0

那你說(shuō)一個(gè)答案,api超過(guò)22,HttpClients都沒(méi)有
2017-12-21 回復(fù) 有任何疑惑可以回復(fù)我~

CloseableHttpClient httpClient = HttpClients.createDefault();

2 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

defaultHttpClient 過(guò)時(shí)處理

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)