打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
纠结了半天的 java.lang.IllegalStateException: getOutputStream() has already been called for this response
今天写一个导出程序,就是把jsp页面上的一个list导出到Excel中,程序写好了,可是就是报一个错误 java.lang.IllegalStateException: getOutputStream() has already been called for this respons。
我的上传代码是在后台写的,有的网友说是:
<-----------------------------------------------------------------------------
OutputStream output=response.getOutputStream();
while((len=in.read(b)) >0)
{
output.write(b,0,len);

}
output.flush();
而不是把response.getOutputStream().write()放到循环体内
在使用完输出流以后调用以下两行代码即可:
out.clear();
out = pageContext.pushBody();
------------------------------------------------------------------------------->
这是在页面上写输出时可能犯的错误,但我没在jsp用response,百般周折后,查到了一位网友的提醒,终于解决了
 
<-----------------------------------------------------------------------------
每个方法都返回的是一个ActionForward对象,而response是ActionForward对象参数,所以就会使response冲突!
所以处理上传的action返回null就可以了
------------------------------------------------------------------------------->
最终我把action里的最后 “return SUCCESS ” 改成了 “return null ”   成功了 !!!
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
java.lang.IllegalStateException异常:简单分析和简单解决方案
java.lang.IllegalStateException:Cannot forward after response has been committed
java.lang.IllegalStateException: attempt to re-open an already-closed object
java.lang.IllegalStateException: Bindings already cleared. 2021-01-28
java.lang.IllegalStateException: Web app root system property already set to different value
java.lang.IllegalStateException: closed
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服