1. if(response.getEntity() != null && response.getEntity().getContent() != null)
  2. {
  3. message = IOUtils.toString(response.getEntity().getContent());
  4. }
会报Content has been consumed错误

这个问题是多次调用HttpEntity.getContent()导致的, Entity中的内容只能读取一次, 参考如下:

You can retrieve the content from the entity only once. If you have 
already extracted the content somewhere, and you try to fetch it 
again, it will throw this IllegalStateException. Check you code and 
make sure that you make this call only once.

看一下:http://blog.csdn.net/boonya/article/details/42740235

Content has been consumed的更多相关文章

  1. HTTPClient网络异常:java.lang.IllegalStateException: Content has been consumed

    在对代码进行重构时候,出现了一个异常,代码的网络请求使用的是HTTPClient: 但是其实代码中没有添加什么,只是添加了两句log: 后来发现是因为将EntityUtils.toString()方法 ...

  2. [置顶] Android开发笔记(成长轨迹)

    分类: 开发学习笔记2013-06-21 09:44 26043人阅读 评论(5) 收藏 Android开发笔记 1.控制台输出:called unimplemented OpenGL ES API ...

  3. HttpClient学习笔记

    HttpClient相关的实体类官方文档地址:http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/ 使用HttpClien ...

  4. How to Preloading content with rel preload

    The preload value of the <link> element's rel attribute allows you to write declarative fetch ...

  5. requests的content与text导致lxml的解析问题

    title: requests的content与text导致lxml的解析问题 date: 2015-04-29 22:49:31 categories: 经验 tags: [Python,lxml, ...

  6. Content Security Policy 入门教程

    阮一峰文章:Content Security Policy 入门教程

  7. android 使用Tabhost 发生could not create tab content because could not find view with id 错误

    使用Tabhost的时候经常报:could not create tab content because could not find view with id 错误. 总结一下发生错误的原因,一般的 ...

  8. 【解决方案】cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns/javaee":security-role-r

    [JAVA错误] cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One o ...

  9. 注意 AppResLib.dll.*.mui 的生成操作应该为 Content

    为 Windows Phone 8 App 添加本地化的时候,发现修改 AppResLib.dll.*.mui 后不仅没有其变化,还发现修改它导致它失效.通过对比代码发现,问题原因是 AppResLi ...

随机推荐

  1. lumen 构建api(dingo api)

    什么是 API API(Application Programming Interface,应用程序编程接口)是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力, ...

  2. ubuntu死机怎么办

    在使用ubuntu的时候由于各种复杂的因素,如软件不兼容,误操作等问题导致"死机"怎么办呢?下面我们来看看如何解决这问题...   可以打开终端模拟器   1 ctrl+alt+t ...

  3. S5Time BCD码存储

    ,时基为1秒. 当使用S5TIME时,定义数值的范围为0~999,而且要指明使用的时基.时基指定了时间单位. S5TIME时基及相应的时间范围如下: 时基 BCD码 时间范围 10 ms 00 10 ...

  4. IIS 7.0 部署MVC

    开发的MVC 3.0 项目,在部署服务上还是与需要花一点功夫,这里把遇到的问题罗列出来. 本文主要介绍IIS 7.5中安装配置MVC 3.0的具体办法! 部署必备: Microsoft .net Fr ...

  5. 防止在iOS设备中的Safari将数字识别为电话号码

    在测试中发现iPad上的Safari总会把长串数字识别为电话号码,文字变成蓝色,点击还会弹出菜单添加到通讯录. 别的地方倒也罢了,如果在用户名中出现数字(手机注册新浪微博的话用户名就是“手机用户xxx ...

  6. Python的第三天

    一.字典 字典是另一种可变容器模型,且可存储任意类型对象. 字典的每个键值(key=>value)对用冒号(:)分割,每个对之间用逗号(,)分割,整个字典包括在花括号({})中 ,格式如下所示: ...

  7. Node.js文件系统、路径的操作详解

    17173 17173 2 75 2014-12-12T05:06:00Z 2014-12-12T05:06:00Z 21 2735 15595 www.17173.com 129 36 18294 ...

  8. 用ADO.NET存入数据库

    点击按钮存入登录名和密码: const string connstr = @"data source=USER-20160705UW\JSQL;initial catalog=Test;in ...

  9. selenium查找动态的iframe的name

    WebElement frame1 = driver.findElement(By.xpath("/html/body/div[9]/div[2]/div/iframe"));dr ...

  10. sas编程-日期相差计算函数 intnx

    sas编程-日期相差计算函数 intnx 示例代码: data _null_;    lastdate=intnx('year',today(),-100);    format lastdate  ...