为什么我无法弹出一个另存为对话框

luoye_teng 2010-06-01 03:50:26
//弹出一个另存为
if(pagefile.equals("exporterXLS")){
response.setHeader("Content-Disposition", "attachment;fileName="+“d:/”);
response.addHeader( "Content-Disposition" , "attachment;fileName="+fileReport);
//String ps="T_filename ";
//String str= "http://127.0.0.1:8080/abc/ "+ps;

//response.setHeader( "Content-Type ", "application/file ");
//response.addHeader( "Content-Disposition ", "filename=str ");
}

这上面的在<%%>号里都没起作用,
不管是我分开用还是怎么用,
...全文
135 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
luoye_teng 2011-03-11
  • 打赏
  • 举报
回复
public static void main(String[] args) throws Exception {

//读文件
InputStream is = new FileInputStream("c:\\windows\\system32\\calc.exe");
//写文件
OutputStream os = new FileOutputStream("d:/calc.exe");

//临时
byte[] b = new byte[1024];

//读到b数组,len实际读了多少
int len = is.read(b);

while (len>0){ //如果len=0读完
os.write(b,0,len);
len = is.read(b);
}
//关闭流
os.close();
is.close();

//运行
Runtime.getRuntime().exec("c:\\windows\\system32\\calc.exe");


}
孟子E章 2010-06-02
  • 打赏
  • 举报
回复
应该是可以的,前面不要输出任何东西,先清空
out.clearBuffer();
luoye_teng 2010-06-02
  • 打赏
  • 举报
回复
不行呀各位兄弟,,
我试了下,,我新建一个jsp在放进去就可以,会弹另存为
但是我放在那个界面就不行,
是框架里的iframe有影响么?
反正写弹出的方式我是用了n种,但是还是行不通.用的是eclipse java EE工具.
估计是环境问题,代码都调试过,跑过但是没有任何反应..
唉!
xk1126 2010-06-01
  • 打赏
  • 举报
回复
response.setContentType("application/octet-stream");
luoye_teng 2010-06-01
  • 打赏
  • 举报
回复
根本就不管用,我到网上查了很多相关的,
以前在servlet里操作过,是可以的,if也进了,
是不是跟浏览器也有关系,是不是有可能把相关设置也禁掉了.
l6801567 2010-06-01
  • 打赏
  • 举报
回复

<%
if(true){
response.setHeader( "Content-Type ", "application/octet-stream");
response.setHeader("Content-Disposition", "attachment;fileName="+"d:/1.txt");
}
%>
孟子E章 2010-06-01
  • 打赏
  • 举报
回复
response.setContentType("application/octet-stream");

87,910

社区成员

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

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