java - 线程“主”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());
解决方案
请参阅 HTTP 状态码:https ://en.wikipedia.org/wiki/List_of_HTTP_status_codes
您的应用程序应处理所有 HTTP 标准状态代码。
推荐阅读
- xml - 沃尔玛加入购物车 XPATH
- windows - 如何将应用程序集成到 Windows 任务栏?
- c++ - 在 c++ 中,upper_bound 和 lower_bound 如何与比较器一起工作?
- javascript - JQuery:如何选择一个没有带有id的父元素的类?
- python - 为什么'else'子句中的打印语句仍然执行?
- javascript - 水平平滑动量滚动
- reactjs - 路由器不渲染
- javascript - 用js点击网站上的“搜索我”按钮在“iFrame”中搜索
- png - Gimp 图层蒙版缺乏精度
- postgresql - postgres 损坏的共享内存