日期:2014-05-18  浏览次数:20610 次

struts1.1+tomcat5.0环境下 IllegalStateException如何处理
我在struts1.1+tomcat5.0环境下,使用action实现了excle文件的下载,用   response.getOutputStream()
输出excle文件流。如果输出成功,则更新JSP页面,但是报   IllegalStateException的
异常,无法更新JSP页面,请教如何处理!

谢谢

代码如下:
                        FileInputStream   fs   =   new   FileInputStream(excelFormPath);
                        HSSFWorkbook   wb   =   new   HSSFWorkbook(fs);

                        createExcel(wb,   reportCommonDTO);

                        String   reportName   =   reportCommonDTO.getExcelReportName();

                        String   clientExcelName   =   getReportFileName(reportName,true);
       
                        response.setHeader( "Content-disposition ",   "attachment;   filename= "+clientExcelName);
                        response.setContentType( "application/msexcel ");
                       
                        OutputStream   fo   =   response.getOutputStream();

                        wb.write(fo);
                        fo.flush();
                        fo.close();
                        return   mapping.findForward( "success ");     //报错了

------解决方案--------------------
你这样做真的不好连贯,你这么写是servlet写法,我建议在页面上处理excel文件和刷新页面