【问题标题】:Error HTTP/1.0 405 Method not Allowed错误 HTTP/1.0 405 方法不允许
【发布时间】:2011-06-21 17:58:22
【问题描述】:

我想建立一个 Http 连接这是我的代码

try
{
HttpClient client = new DefaultHttpClient();
HttpPost httpMethod = new HttpPost("http://www.google.co.in/");
String requestBody = "some text";
HttpMethod.setEntity(new StringEntity(requestBody));
HttpResponse response = client.execute(httpMethod);
textView.setText(response.getStatusLine().toString());
}

但我无法获得“HTTP/1.0 405 Method not Allowed”错误 我会感谢你的帮助

【问题讨论】:

    标签: android http-status-code-405


    【解决方案1】:

    也许您应该尝试使用接受 POST 请求的服务器。您的代码可能没有任何问题,Google 的首页只是不做 POST。

    我能想到的可以使用的服务器的一个简单示例是JSFiddle's echo feature。我相信他们不会介意的。

    【讨论】:

    • 是的,使用HttpGet 类并使用setParams 方法。
    【解决方案2】:

    表示请求的 URL 不接受 POST 方法。使用 GET 重试。

    【讨论】:

      猜你喜欢
      • 2014-12-12
      • 2017-10-16
      • 2020-02-13
      • 2016-08-24
      • 2018-01-07
      • 2018-06-05
      • 1970-01-01
      • 2021-12-20
      • 2017-11-13
      相关资源
      最近更新 更多