HttpClient不能实例化的问题怎么解决
测试使用httpclient
public class TestJetty {
public static void main(String[] args) {
HttpClient httpClient = new HttpClient();
GetMethod getMethod = new GetMethod("http://www.baidu.com/");
try {
getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler());
int statusCode = httpClient.executeMethod(getMethod);
if (statusCode != HttpStatus.SC_OK) {
System.err.println("Method failed: " + getMethod.getStatusLine());
}
//读取内容
byte[] responseBody = getMethod.getResponseBody();
//处理内容
System.out.println(new String(responseBody));
} catch (Exception e) {
e.printStackTrace();
}finally{
getMethod.releaseConnection();
}
}
}
但是执行报错:Cannot instantiate the type HttpClient,求大侠帮忙
我就估计会有人遇到这种问题
别用4.X版本的 用3.X的 升级后那个类变成接口了