小编Roz*_*ozy的帖子

错误连接被拒绝

我想与我自己的servlet建立一个Http连接.这是我的代码:

try
{
    HttpClient client = new DefaultHttpClient();
    HttpPost httpMethod = new HttpPost("http://localhost:8080/getHeader/HeaderServlet");
    httppost.setHeader("Content-Type", "application/x-www-form-urlencoded"); 
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    String response = client.execute(httppost, responseHandler);
    String result = response.toString();
}
Run Code Online (Sandbox Code Playgroud)

但我无法,我得到错误:

org.apache.http.conn.HttpHostConnectionException:Connection to http://localhost:8080 refused
Run Code Online (Sandbox Code Playgroud)

我将感谢你的帮助

android

48
推荐指数
4
解决办法
8万
查看次数

错误HTTP/1.0 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 = client.execute(httpMethod);
textView.setText(response.getStatusLine().toString());
}
Run Code Online (Sandbox Code Playgroud)

但我无法得到"HTTP/1.0 405方法不允许"错误,我将感谢你的帮助

android http-status-code-405

9
推荐指数
2
解决办法
1万
查看次数

如何从HttpResponse读取bytearray?

我正在使用以下代码建立http连接:

HttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
HttpResponse response = client.execute(httpPost);
Run Code Online (Sandbox Code Playgroud)

我想从响应对象中读取一个bytearray.

我该怎么办?

android

4
推荐指数
1
解决办法
9014
查看次数

标签 统计

android ×3

http-status-code-405 ×1