DownloadAction下载文件

For_suzhen 2006-11-21 04:12:36
如题,我该怎么实现
...全文
196 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
tidesoft_whr 2006-12-06
  • 打赏
  • 举报
回复
我也可以好好学学了。哈哈
ncowboy 2006-11-22
  • 打赏
  • 举报
回复
response.reset();
// 准备文件头
response.addHeader("Content-disposition", " inline; filename=xzxy_"
+ fileName);
response.setContentType(contentType);

try {
if (output == null) {
output = response.getOutputStream();
}
if (fis == null) {
fis = new FileInputStream(file);
}
byte[] b = new byte[1024];
int i = 0;

while ((i = fis.read(b)) > 0) {
output.write(b, 0, i);
}
output.flush();
} catch (Exception e) {
log.warn(e);
} finally {
if (fis != null) {
fis.close();
fis = null;
}
if (output != null) {
output.close();
output = null;
}
}
return null;
For_suzhen 2006-11-21
  • 打赏
  • 举报
回复
没人回答?不用DownloadAction了,问同事讨了一个Action的。

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧