jsp下载,ie下无法下载,急!

Jay_xiaolei 2011-03-22 04:09:12
<%@page language="java" contentType="application/x-msdownload" import="java.io.*,java.net.*" pageEncoding="utf-8"%><%

String fileName = request.getParameter("fileName");
String filePath = request.getParameter("filePath");
response.reset();
response.setContentType("application/x-download");

String filenamedownload = filePath;
String filenamedisplay = fileName;


filenamedisplay = URLEncoder.encode(filenamedisplay,"UTF-8");
response.addHeader("Content-Disposition","attachment;filename=" + filenamedisplay);

OutputStream output = null;
FileInputStream fis = null;
try
{
output = response.getOutputStream();
fis = new FileInputStream(filenamedownload);
byte[] b = new byte[1024];
int i = 0;
while((i = fis.read(b)) > 0)
{
output.write(b, 0, i);
}
output.flush();
out.clear();
out = pageContext.pushBody();
}
catch(Exception e)
{
System.out.println("Error!");
e.printStackTrace();
}
finally
{
if(fis != null)
{
fis.close();
fis = null;
}
if(output != null){
output.close();
output = null;
}
}
%>
...全文
118 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jay_xiaolei 2011-03-22
  • 打赏
  • 举报
回复
现在结不了贴,24小时才能结贴
Jay_xiaolei 2011-03-22
  • 打赏
  • 举报
回复
不需要回答了,代码没有问题,是公司的框架的按钮不支持
t150ckh 2011-03-22
  • 打赏
  • 举报
回复
有弹出一个下载框没啊。
t150ckh 2011-03-22
  • 打赏
  • 举报
回复
是IE没有反应还是其它问题啊!把问题说详细点咯。

81,122

社区成员

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

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