严重: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
java.lang.IllegalStateException: getOutputStream() has already been called for this response
解决方案 »
- 求助:java.sql.SQLException: Already closed总是自动关闭(奇怪)
- jsp检索条件以及检索结果的设置问题
- 关于excel导出问题。懂的出点力气,不懂的凑点人气。
- struts与slf4j有冲突吗?
- 请各位高手解决一下这个JSP问题
- 信息提交出错,大家帮帮我啊!
- jsp中如何取SCOPE_IDENTITY()
- 如何将汉字转换成内码?
- 请问如何改变request变量的值?急,在线等,请救命!
- 请问ServletResponse.setContentType(String type)中的type 有哪些可选项??
- 200分2贴 求AJAX从后台取值
- 尚学堂 张志宇lucene视频相关的代码谁有?
getOutputStream() has already been called for this response
这句就说的很清楚
一Action中有方法:
public void exportExcel() throws Exception {
HttpServletResponse response = ServletActionContext.getResponse();
response.reset();
response.setContentType("application/vnd.ms-excel");
//把数据库中查询的数据用jxl写到excel中
//具体是写到response.getOutputStream()流中
WritableWorkbook wwb = Workbook.createWorkbook(response.getOutputStream());
//……
//然后返回此流到客户端下载
}问题是:能直接打开生成的excel,但选择保存就出那个错了。
getOutputStream() has already been called for this response
这句就说的很清楚
这句代码建议分解成
OutputStream out=response.getOutputStream();
WritableWorkbook wwb = Workbook.createWorkbook(out);
out.fush();
out.close();
http://blog.csdn.net/taochenpfj/archive/2009/07/08/4331928.aspx
http://hi.baidu.com/jjpro/blog/item/9412ae23f3049b42ac34dec1.html
但我的action中的方法返回类型都是void的,我也试了改成String然后return null。还是一样啊。
看看这个。