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);
复制代码