输出流下载问题? Socket closed
项目为struts2+spring+ibatis前台为extjs
页面有导出功能, 可将数据导到excel中, 并下载
但遇到个问题
如果导出的数据过多(超过1000条), 当使用ie浏览器点导出按钮后, 页面弹出下载提示(有打开、保存功能)
此时不进行操作
大概过1分钟左右的时间, 控制台会报出如下异常:
<2011-11-24 上午08时50分47秒 GMT> <Error> <HTTP> <BEA-101017> <[weblogic.servlet.internal.WebAppServletContext@ee9368 - appName: '_appsdir_SEC_dir', name: 'SEC', context-path: '/SEC'] Root cause of ServletException.java.net.SocketException: Socket closed at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:525) at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:504) at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:382) Truncated. see log file for complete stacktrace
this.getResponse().setHeader("Cache-Control", "no-cache");this.getResponse().setDateHeader("Expires", 0);this.getResponse().setContentType("application/vnd.ms-excel;charset=UTF-8");this.getResponse().setHeader("Content-Disposition", "attachment;filename=" + new String((title + ".xls").getBytes("GBK"), "iso8859-1"));WritableWorkbook workbook = Workbook.createWorkbook(this.getResponse().getOutputStream());// ......excel表格内文字边框等样式 此处省略// ......查数据库 遍历list往表格内写数据 此处省略workbook.write();workbook.close();