httpclient3与httpclient4访问的一些区别

来源:互联网 发布:农村淘宝发展现状分析 编辑:程序博客网 时间:2024/04/19 06:46
httpclient3访问如下:

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. HttpClient client = new HttpClient();  
  2. GetMethod method = new GetMethod(url);  
  3. int statusCode = client.executeMethod(method);  
  4. method.getResponseBody();  

在3中httpclient是类。

httpclient4:
[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. HttpClient client = new DefaultHttpClient();  
  2. HttpGet method = new HttpGet(url);  
  3. HttpResponse httpResponse = client.execute(method);  
  4. httpResponse.getEntity().getContent();  

在4中httpclient是接口了。

差别还是比较大的。如果过度的话,还是要看官方文档的,特别是设置参数之类的。

0 0
原创粉丝点击