源码

android – 获取HttpResponse的响应体


我这样做了:

response = httpclient.execute(targetHost, httppost); 
    if(response.getStatusLine().getStatusCode() == 200)
                        {
    HttpEntity entity = response.getEntity();
    System.out.println("Entity:"+entity);
  if (entity != null) 
                            {
        String responseBody = EntityUtils.toString(entity);
        System.out.println("finalResult"+responseBody.toString());
                            }

关于它的事情是第一个println()显示:org.apache.http.conn.BasicManagedEntity@481e8150这是好的.

但第二个System.out.println(“finalResult”responseBody.toString());仅显示此finalResult.那么这有什么问题:

String responseBody = EntityUtils.toString(entity);
            System.out.println("finalResult"+responseBody.toString());

???

重要信息此HttpEntity实体= response.getEntity();等于org.apache.http.conn.BasicManagedEntity@481e8150.所以问题必须在这里:

String responseBody = EntityUtils.toString(entity);.

请帮忙!!!

(0)

本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/android-huoquhttpresponsedexiangyingti.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 25, 2019 at 11:07 下午

热评文章