//弹出一个另存为
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 "); 
        }这上面的在<%%>号里都没起作用,
 不管是我分开用还是怎么用,

解决方案 »

  1.   

     response.setContentType("application/octet-stream");  
      

  2.   


    <%
    if(true){
    response.setHeader( "Content-Type ", "application/octet-stream");  
    response.setHeader("Content-Disposition", "attachment;fileName="+"d:/1.txt");
       }
      %>
      

  3.   

    根本就不管用,我到网上查了很多相关的,
      以前在servlet里操作过,是可以的,if也进了,
    是不是跟浏览器也有关系,是不是有可能把相关设置也禁掉了.
      

  4.   

    response.setContentType("application/octet-stream"); 
      

  5.   

    应该是可以的,前面不要输出任何东西,先清空
    out.clearBuffer();
      

  6.   

    不行呀各位兄弟,,
      我试了下,,我新建一个jsp在放进去就可以,会弹另存为
    但是我放在那个界面就不行,
      是框架里的iframe有影响么?
    反正写弹出的方式我是用了n种,但是还是行不通.用的是eclipse  java EE工具.
    估计是环境问题,代码都调试过,跑过但是没有任何反应..
    唉!
      

  7.   

    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");


    }