IE 不使用 jQuery 文件下载插件下载文件

IE doesn't download file with jQuery File Download plugin

我在 java 代码中使用 jQuery 文件下载插件,在 Firefox 和 Chrome 上工作正常,但无法在 Internet Explorer 上启动下载。 我设置这些 headers:

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

在我的 java 脚本中,我使用以下代码:

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

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

URL: async/paas/caaas/downloadCertificate/591C94
方法:GET (In sospeso...) 结果: (In sospeso...)
Tipo: (In sospeso...) Ricevuti: 0 B
Tempo impiegato: (In sospeso...)
发起人:esplorazione frame

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

我通过在 response.setHeader:

之前添加这一行解决了这个问题
response.reset();

您使用的是 spring 安全版本 4 或更高版本吗?

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

Spring 安全 在版本 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>

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

祝你一切顺利