0
我已经努力解决这个问题,但我不能。我试图从apache使用httpClient 4.1.2。作为逻辑,我从这个例子开始,问题是我有一些奇怪的错误,我不明白。这是处理:ClientWithResponseHandler示例给出一个ERROR?
package ClientWithResponseHandler;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
public class Main {
public final static void main(String[] args) throws Exception {
HttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet("http://www.google.com/");
System.out.println("executing request " + httpget.getURI());
// Create a response handler
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = **httpclient.execute(httpget, responseHandler);**
System.out.println("----------------------------------------");
System.out.println(responseBody);
System.out.println("----------------------------------------");
} finally {
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
}
}
}
的错误是 “httpclient.execute(HTTPGET,ResponseHandler所);” IT说它找不到方法执行(HttpGet,ResponseHandler) 这个问题不应该是这个例子的工作吗?我究竟做错了什么?! :S