一个struts1.2.8下面怪异问题

06-02-17 xiaohuilang
我写了一个输出数据的excel表的程序,执行时应该先执行wb.write(fileOut);然后执行return语句,现在的现象是执行完write之后并没提示保存文件,而是跑去执行return,然后才让我保存文件。。。。

下面为action代码

try {

String SQLStatement =

"select * from t_sap_customer where customer_id = '300314'";

httpServletResponse.reset();

httpServletResponse.setContentType("application/txt; charset=GB2312");

httpServletResponse.setHeader("Content-disposition",

"attachment; filename=customer.xls");

ToExcelHelper excelHelper = new ToExcelHelper();

HSSFWorkbook wb = excelHelper.TransSalaryToExcel(SQLStatement);

ServletOutputStream fileOut = httpServletResponse.getOutputStream();

wb.write(fileOut);

}

catch (Exception e) {

e.printStackTrace();

}

return actionMapping.findForward("Success");

帮帮忙呀

xiaohuilang
2006-02-17 11:58
这个程序在1.1下面没问题,为什么try{}里面东西没执行完就去执行return...郁闷

xiaohuilang
2006-02-17 13:53
谁知道原因?

xiaohuilang
2006-02-17 14:44
搞定了,加个flush就行

猜你喜欢