【问题标题】:HttpPost: Send image to web server and receive requestHttpPost:将图像发送到 Web 服务器并接收请求
【发布时间】:2013-11-25 19:42:57
【问题描述】:

我是 android 新手,所以请容忍我使用不正确的术语。我正在编写一个有助于用图像识别位置的应用程序。 已将捕获的图像发送到 Web 服务器。 但是没有收到服务器的回复???

侦听和接收来自网络服务器的有关捕获图像位置的信息并显示给用户。

hier 是发出请求的代码:

try {
                response = httpClient.execute(postRequest);
                entityReceived = response.getEntity();
                try {
                    String result = EntityUtils.toString(entityReceived, "UTF-8");
                    System.out.println("Response: " + result);
                } catch (ClientProtocolException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
          } 

【问题讨论】:

    标签: android


    【解决方案1】:

    您可以使用以下代码检查状态码。

    HttpResponse response = httpclient.execute(httpRequest);
    int status = response.getStatusLine().getStatusCode();
    

    还有Check Status Code Here

    【讨论】:

    • 返回任何值,因为它总是在 HttpResponse response = httpclient.execute(httpRequest); 上崩溃
    • 我找不到你..请解释一下。
    【解决方案2】:

    我认为您的帖子中存在问题,您没有将有效的内容发布到 url 想要的 url。通过在浏览器中使用该 URL 和您的帖子来检查您的帖子,会出现什么结果。

    【讨论】:

      猜你喜欢
      • 2011-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多