httpclient3与httpclient4访问的一些区别

xiaoxiao2021-02-28  111

httpclient3访问如下: [java]  view plain  copy   HttpClient client = new HttpClient();   GetMethod method = new GetMethod(url);   int statusCode = client.executeMethod(method);   method.getResponseBody();   在3中httpclient是类。 httpclient4: [java]  view plain  copy   HttpClient client = new DefaultHttpClient();   HttpGet method = new HttpGet(url);   HttpResponse httpResponse = client.execute(method);   httpResponse.getEntity().getContent();   在4中httpclient是接口了。 差别还是比较大的。如果过度的话,还是要看官方文档的,特别是设置参数之类的。

转载请注明原文地址: https://www.6miu.com/read-34401.html

最新回复(0)