【发布时间】:2021-01-06 06:58:46
【问题描述】:
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());
【问题讨论】:
-
405 状态码表示该请求方法不允许用于特定资源。更多详情请参考developer.mozilla.org/en-US/docs/Web/HTTP/Status/405。
-
欢迎来到 Stack Overflow。请阅读How to Ask。只是在这里转储代码并不是获得帮助的好方法。请提供一些关于您正在尝试执行的操作的解释以及 full 错误消息,以及行号和回溯。
标签: java get httpconnection