java.lang.IllegalStateException: getOutputStream() has already been called for this response

来源:互联网 发布:matlab 复制矩阵 编辑:程序博客网 时间:2024/05/20 05:08
  在jsp或者在servlet中有时要用到response.getOutputStream(),但是此时会在后台报这个错误java.lang.IllegalStateException: getOutputStream() has already been called for this respons,这问题困扰了我好久都没解决,最近这个项目中我又遇到了,下定决心一定要解决掉,最后终于让我给找到解决的方法了,这个异常时因为response.getOutputStream()跟response.getWriter()相冲突早场的,呵呵!现在记录下,发出来和大家共享下,希望能帮到遇到同样问题的朋友们,解决方法如下: out.clearBuffer(); out = pageContext.pushBody();在调用response.getOutputStream()之前加上上面两代码,就ok了!