나는 이것을 해결하기 위해 열심히 노력했지만 나는 할 수 없었다. 아파치에서 httpClient 4.1.2를 사용하려고합니다. 이 예제로 시작한 논리로서, 문제는 제가 이해하지 못하는 이상한 오류가 있다는 것입니다. 이 거래입니다 :ClientWithResponseHandler 예제 오류가 발생 했습니까?
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