【问题标题】:IE doesn't download file with jQuery File Download pluginIE 不使用 jQuery File Download 插件下载文件
【发布时间】:2015-02-19 15:19:10
【问题描述】:

我在我的 java 代码中使用了 jQuery File Download 插件,并且可以在 Firefox 和 Chrome 上正常工作,但不能使用 Internet Explorer 开始下载。 我设置了这些标题:

response.setHeader("Set-Cookie", "fileDownload=true; path=/");
response.setHeader("Content-Disposition","attachment; filename="+file);

在我的 javascript 中,我使用以下代码:

$.fileDownload(
    "/async/paas/caaas/downloadCertificate/"+serialNumber, 
    {
        successCallback: function (url) {
            //
        },
        failCallback: function (HttpServletResponse, url) {
            $(“#modalDownloadFailedCertificate”).modal("show");
        }
    }
);
return false;

在 IE 中,使用 F12 模式,我有这一行:

网址:async/paas/caaas/downloadCertificate/591C94
方法:GET(在 sospeso 中......) Risultato:(在 sospeso...)
提示:(在 sospeso 中......) Ricevuti:0 B
Tempo impiegato:(在 sospeso...)
Iniziatore: esplorazione 框架

有人有同样的问题吗? 提前致谢

【问题讨论】:

    标签: java javascript jquery internet-explorer controller


    【解决方案1】:

    我通过在 response.setHeader 之前添加这一行来解决它:

    response.reset();
    

    【讨论】:

      【解决方案2】:

      您使用的是 Spring Security 版本 4 或更高版本吗?

      jquery 文件下载在内部使用 iframe。

      Spring security 在版本 4 中,出于安全原因,x-frame-options 设置为 'DENY' 以阻止 iframe。

      所以要使用 jquery 文件下载,您必须将选项值更改为“SAMEORIGIN”。

      <security:http auto-config="true" use-expressions="true">
          <security:headers>
              <security:frame-options policy="SAMEORIGIN"/>
          </security:headers>
          ..........
      </security:http>
      

      将设置添加到安全上下文文件

      祝你好运。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-12-23
        • 2013-01-18
        • 1970-01-01
        • 1970-01-01
        • 2017-12-11
        • 1970-01-01
        • 2019-11-09
        相关资源
        最近更新 更多