HTTPClient 工具類的使用

2021-07-27 10:48:46 字數 1771 閱讀 9666

// 建立http get請求

// 執行請求

// 判斷返回狀態是否為200

* description:模擬不帶引數的get請求

* @date 2023年2月24日下午7:09:09

* @param url

* @param param

* @return

*/public static string doget(string url)

/***

* title: dopost

* description:模擬帶引數的post請求

* @date 2023年2月24日下午7:10:19

* @param url

* @param param

* @return

*/public static string dopost(string url, mapparam)

// 模擬表單

}// 執行http請求

* description:模擬bu帶引數的post請求

* @date 2023年2月24日下午7:10:19

* @param url

* @param param

* @return

*/public static string dopost(string url)

/***

* title: dopostjson

* description:

* @date 2023年2月24日下午7:11:01

* @param url

* @param json

* @return

*/public static string dopostjson(string url, string json) catch (exception e) finally catch (ioexception e)

} return resultstring;

}}

HttpClient工具類封裝

httpclient是apache jakarta common下的子專案,用來提供高效的 最新的 功能豐富的支援http協議的客戶端程式設計工具包,並且它支援http協議最新的版本和建議。httpclient已經應用在很多的專案中,比如apache jakarta上很著名的另外兩個開源專案cact...

httpClient訪問遠端介面工具類

功能 httpclient訪問遠端介面工具類 是否為get方式請求 boolean isget get equalsignorecase requestmethod boolean ispost post equalsignorecase requestmethod boolean isput pu...

HttpClient介面呼叫工具類

httpclient介面呼叫工具類 description 請求工具類 建立http get請求 執行請求 判斷返回狀態是否為200 不帶引數的get請求 public static string doget string url 帶引數的post請求 public static string do...