jsf - Safari 无法正确下载文件名
问题描述
I've a file called "Screen Shot 2552018-09-10 at 08.17.168792378923879423789324789234789234789023478943829009872438723487990724490237842378947289379802323478923478974283923487943287937428978932478324789873924789324879034278978923478923478923470897890432879 (1).png" and my code is using command link to get it. 这在 Chrome 中运行良好,但在 Safari 中却不行。Safari 会更改路径 URL 中某些内容的文件名。
例如:url 是 localhost:8080/app/documents/771 所以这个文件被重命名为 771
野生动物园 14
铬合金
代码
<h:commandLink value="#{document.fileName}" ajax="false" immediate="true"
onclick="PrimeFaces.monitorDownload(PF('blockUIWV').show(), PF('blockUIWV').hide()); _paq.push(['trackEvent', 'Documents', 'Download document,'Download']);">
<p:fileDownload value="#{bean.downloadDocument(document.myDocument)}" />
</h:commandLink>
我看到 HTML5 有一个下载属性,所以我试图强制它。
代码
<h:commandLink value="#{document.filename}" ajax="false" immediate="true"
pt:download="#{document.filename}
onclick="PrimeFaces.monitorDownload(PF('blockUIWV').show(), PF('blockUIWV').hide()); _paq.push(['trackEvent', 'Documents', 'Download document,'Download']);">
<p:fileDownload value="#{bean.downloadDocument(document.myDocument)}" />
</h:commandLink>
即使进行了此更改,该文件的名称也不正确。但现在名称是“文档”(我的网址的一部分)。Safari 出了什么问题,我该如何解决?
环境
Primefaces 6.2
JSF 2
解决方案
因此,经过研究,我认为您应该将此问题报告给 Apple。
见 PF 票:https ://github.com/primefaces/primefaces/issues/6327
此文件名在 Chrome、Firefox、MS Edge 中运行良好。它仅在 Safari 中不起作用。
在 PF 9.0 中,我们添加了一个新功能 AJAX 文件下载,它确实可以工作https://github.com/primefaces/primefaces/issues/5978并且 Safari 会正确下载文件名。
推荐阅读
- java - 不确定如何使用
在链表中创建节点时 - javascript - 如何在cheerio nodejs中选择相同的多个元素之一?
- javascript - HTML复选框“onclick”创建按钮问题
- javascript - Angular Router 将数据传递给组件
- github - 我正在尝试使用 Azure Devops 集成 IBM 集成总线,但收到类似 Not found mqsipackagebar: null 的错误
- python - 在for循环中将空字符串附加到列表中的最后一个值
- python - 如何将 matplotlib 图保存到 hdf5 文件?
- typescript - Vue 3:控制台说状态有 ID,但在 vuex 存储中,它是“null”
- javascript - 从特定选择框中选择项目时提交按钮不起作用
- c# - Azure 应用程序洞察:EventCounterCollectionModule 按需启用/禁用