纠结了半天的 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 ” 成功了 !!!
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。