多份csv文件输出问题
litex 2006-05-08 01:06:34 问题如下:
点击我的页面上的button,到服务器端会生成多份csv文件,如何在客户端多次弹出保存对话框,能够将生成的csv文件全部保存到客户端,我现在是在逻辑里循环调用如下代码
public void pdfOut(HttpServletResponse res, String pdfFullPathName)
throws THBException
{
String fileName = pdfFullPathName;
int pos = 0;
while (pos != -1) {
pos = fileName.indexOf("\\");
if (pos >= 0) {
fileName = fileName.substring(pos + 1);
}
}
//ファイル出力
OutputStream os = null;
final File f = new File(pdfFullPathName);
try {
FileInputStream fis = new FileInputStream(pdfFullPathName);
final byte[] buff = new byte[4096];
res.setContentType("application/pdf");
res.setHeader("Content-disposition",
"attachment;filename=" + fileName);
res.setContentLength((int) f.length());
try {
os = (OutputStream)res.getOutputStream();
while (true) {
final int len = fis.read(buff, 0, buff.length);
if (len == -1) {
break;
}
os.write(buff, 0, len);
}
} catch (IOException e) {
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e1) {
fis = null;
}
}
}
} catch (FileNotFoundException e) {
} finally {
if (os != null) {
try {
os.flush();
os.close();
} catch (IOException e) {
os = null;
}
}
}
f.delete();
}
但是当循环时就会出现异常“递交的response不能再forward”,请各位大虾指点一二,谢谢!