线程“main”java.io.ioexception中的异常:服务器返回http响应代码:405

gdx19jrr  于 2021-06-26  发布在  Java
关注(0)|答案(1)|浏览(605)
ULR url = new URL(urlString);

HttpURLConnection con = (HttpURLConnection) url.openConnection();

con.setRequestMethod("GET");

con.connect();

BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); 

String inputLine;

StringBuffer response = new StringBuffer();

while ((inputLine = in.readLine()) != null) 

{

response.append(inputLine);

}

in.close();

System.out.println(response.toString());
2nbm6dog

2nbm6dog1#

请参阅http状态代码:https://en.wikipedia.org/wiki/list_of_http_status_codes
应用程序应该处理所有http标准状态代码。

相关问题