首页 > 解决方案 > 线程“主”java.io.IOException 中的异常:服务器返回 HTTP 响应代码:405

问题描述

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());

标签: javagethttpconnection

解决方案


请参阅 HTTP 状态码:https ://en.wikipedia.org/wiki/List_of_HTTP_status_codes

您的应用程序应处理所有 HTTP 标准状态代码。


推荐阅读