getOutputStream() has already been called for this response

来源:互联网 发布:windows live id大全 编辑:程序博客网 时间:2024/06/03 17:40

       用jsp实现文件下载、图片验证码等功能时,有时会产生getOutputStream() has already been called for this response异常信息。

       原因是在将jsp代码编译成servlet后,程序中会调用response.getWriter(),而这段代码和你编写的response.getOutputStream()相冲突,程序认为他们的作用是一样的,没必要调用两次,所以在运行时,程序报getOutputStream() has already been called for this response。

      解决办法:

      使用完输出流以后添加以下两行代码:

out.clear();out = pageContext.pushBody();


交流探讨到我的新浪微博:http://weibo.com/tianrui1990

欢迎关注技术分享微信公众号:JavaQ

     


原创粉丝点击