Android 错误HTTP/1.0 405方法不允许
我想建立一个Htttp连接这是我的代码Android 错误HTTP/1.0 405方法不允许,android,http-status-code-405,Android,Http Status Code 405,我想建立一个Htttp连接这是我的代码 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 = clie
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方法不允许”错误
我将非常感谢您的帮助也许您应该尝试使用接受POST请求的服务器。你的代码可能没什么问题,谷歌的头版根本就没有帖子
我能想到的一个服务器的简单例子是。我相信他们不会介意。这意味着请求的URL不接受POST方法。使用GET重试。Yep,使用
HttpGet
类并使用setParams
方法。