"http://www.example.com/a?s=12"
과 같은 문자열을 사용하여 URL 객체를 만듭니다. 문자열 serverResponse
에서 HTML 응답을 읽었습니다. 이 문자열에는 JavaScript 및 CSS가 포함 된 페이지의 전체 HTML이 있어야합니다. 그러나 이상하게도 "http :"라는 단어가 응답에있는 모든 URL에서 누락되었습니다 (예 : "http://example.com"
대신 "//asd.com"
이 표시됨). 어떤 아이디어?HttpUrlConnection의 응답에서 'http'라는 단어가 생략되었습니다.
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer serverResponse = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
serverResponse.append(inputLine);
System.out.println(inputLine);
}
in.close();
System.out.println(serverResponse);
감사합니다. 이로 인해 혼란이 사라졌습니다. – zafar142003