zoukankan      html  css  js  c++  java
  • downlaod 文件的窗口

    (1)  如果文件是可访问的web资源, <a href=""> 最简洁。

    (2) 如果是动态生成的资源:

    server端:

    response.setContentType("application/octet-stream;"); //Mime类型,随文件而变
    response.addHeader("Content-Disposition", "attachment;filename=\""
      + URLEncoder.encode(responseFileName, "UTF-8") + "\"");
    ous = response.getOutputStream();
    ous = new BufferedOutputStream(ous);
    ins = new BufferedInputStream(new FileInputStream(exportFile));
    org.apache.commons.io.IOUtils.copy(ins, ous);

    js端:

    var urlStr = "/xxx/xxx/xx.action;jsessionid="+ window.jsessionid+"?resId=" + resId;
    //window.open(urlStr, "_blank");
    window.open(urlStr, "downframe");//参数target使用“downframe”会打开浏览器的download窗口

    以上内容供参考,如有问题还望指出。

  • 相关阅读:
    PatentTips
    PatentTips
    PatentTips
    PatentTips – Java native function calling
    PatentTips
    PatentTips
    PatentTips
    PatentTips
    PatentTips
    PatentTips
  • 原文地址:https://www.cnblogs.com/amosleaf/p/2880265.html
Copyright © 2011-2022 走看看