HttpClient是Apache Jakarta Common下的子項目,用來提供高效的、最新的、功能豐富的支持HTTP協議的客戶端編程工具包,而且它支持HTTP協議最新的版本和建議。java
URI uri = new URIBuilder("http://www.baidu.com").setParameter("wd", "java").build();
HttpGet httpGet = new HttpGet(uri);
複製代碼
HttpPost httpPost = new HttpPost("http://www.baidu.com");
httpPost.setEntity(new StringEntity(stringContent));
複製代碼
HttpPost httpPost = new HttpPost("http://www.baidu.com");
List<NameValuePair> parameters = new ArrayList<NameValuePair>(0);
parameters.add(new BasicNameValuePair("scope", "project"));
parameters.add(new BasicNameValuePair("q", "java"));
// 構造一個form表單式的實體
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(parameters);
httpPost.setEntity(formEntity);
複製代碼