나는 (브라우저 벌금 실행)이 URL이 있습니다. 나는 시도했다 :HttpGet 매개 변수 인코딩을 어지럽히는 방법은 무엇입니까? 내가 실행 HttpClient를 사용하려고 시도하고</p> <p><a href="https://api-test.company.com/contacts/[email protected]" rel="nofollow">https://api-test.company.com/contacts/[email protected]</a></p> <p>:
String URL = "https://api-test.company.com/contacts?q=" + URLEncoder.encode("[email protected]");
DefaultHttpClient client = new DefaultHttpClient();
HttpGet c = new HttpGet(URL);
HttpResponse response = client.execute(c);
String resultContent = myRestCall.GetResponseText(response);
이 오류 반환 :
QUERY_PARAMunable는 쿼리 문자열 '[email protected]'
을 구문 분석을 그리고 나는 시도했다 :
GetMethod method = new GetMethod("https://api-test.company.com/contacts/?q=");
method.setQueryString(new NameValuePair[] {new NameValuePair("email", "[email protected]")});
HttpGet c = new HttpGet(method.toString());
DefaultHttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(c);
다음 중 하나가 반환됩니다.
java.lang.IllegalStateException : 대상 호스트가 null이 아니어야합니다. 또는 매개 변수로 설정하십시오.
그래서이 간단한 GET 요청을 정확히 정확히 구문 분석합니까?
감사합니다.
정확하게 누가 잘못 말했는지 말하십시오. –
나는 당신이 무엇을 요구하고 있는지 잘 모르겠습니다. 주어진 매개 변수로 내 GET 요청을 제대로 실행하는 방법을 묻습니다. – Jason