java.lang.IllegalStateException: getOutputStream() has already been called for this response解决方法及解释
2011-10-12 15:42
1241 查看
out = pageContext.pushBody()是什么意思?
由于jsp container在处理完成请求后会调用releasePageContet方法释放所用的PageContext object,并且同时调用getWriter方法,由于getWriter方法与在jsp页面中使用流相关的getOutputStream方法冲突,所以会造成这种异常,解决办法是:只需要在jsp页面的最后加上两条语句: out.clear();
out=pageContext.pushBody();即可(其中out,pageContext均为jsp内置对象!)
首先你要知道pushBody()的作用是保存当前的out内置对象,并更新PageContext中Page范围内Out流对象。至于为什么要加上这句话,是因为JSP容器在处理完成请求后会调用releasePageConter方法释放所有的PageContestObject,并且同时调用getWriter方法。由于getWriter方法与在JSP页面中使用流相关的getOutputStream方法冲突,所以会造成这种异常,解决方法就是楼上给的一样,只需要在JSP页面的最后加上这两条语句。
out.clear(); out = pageContext.pushBody(); 是什么意思? 为什么不加入了就报异常: java.lang.IllegalStateException: getOutputStream() has already been called for this response
由于jsp container在处理完成请求后会调用releasePageContet方法释放所用的PageContext object,并且同时调用getWriter方法,由于getWriter方法与在jsp页面中使用流相关的getOutputStream方法冲突,所以会造成这种异常,解决办法是:只需要在jsp页面的最后加上两条语句: out.clear();
out=pageContext.pushBody();即可(其中out,pageContext均为jsp内置对象!)
首先你要知道pushBody()的作用是保存当前的out内置对象,并更新PageContext中Page范围内Out流对象。至于为什么要加上这句话,是因为JSP容器在处理完成请求后会调用releasePageConter方法释放所有的PageContestObject,并且同时调用getWriter方法。由于getWriter方法与在JSP页面中使用流相关的getOutputStream方法冲突,所以会造成这种异常,解决方法就是楼上给的一样,只需要在JSP页面的最后加上这两条语句。
相关文章推荐
- java.lang.IllegalStateException:getOutputStream() has already been called for this response的解决方法
- java.lang.IllegalStateException: getOutputStream() has already been called for this response的解决办法
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response,java.la
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response解决方案
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getWriter() has already been called for this response问题解决
- java.lang.IllegalStateException: getWriter() has already been called for this response问题解决
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- Java.lang.IllegalStateException: getOutputStream() has already been called for this response