【发布时间】:2018-04-25 11:31:31
【问题描述】:
我想在我的网站上放一个下载链接,以便用户可以下载文件template.csv。该文件是静态的,位于我的/grails-app/assets 文件夹的根目录下。
在我的page.gsp 中,我尝试了两种方法,但均无济于事:
-
<a href="assets/template.csv" download="template.csv">Download the template</a>- 这会导致下载一个
template.csv文件,但内容是page.gsp的html 代码,而不是我在资产中上传的文件的原始内容。
- 这会导致下载一个
-
<a href="${assetPath(src: "template.csv", absolute: true)}" download="template.csv">Download the template</a>- 生成的 html 文件有一个指向
localhost:8080/mysite/assets/template.csv的链接,但单击它会提示错误消息:Failed - no file。
- 生成的 html 文件有一个指向
什么是做我想要实现的正确方法?我需要添加额外权限以允许下载我的文件是否存在问题?
我们的 webapp 依赖于一个相当古老的技术栈:
- Grails 2.3.4
- 插件asset-pipeline-2.2.5
【问题讨论】:
-
添加 grails 版本和有关您正在使用的任何资产处理插件的信息
-
@TuomasValtonen 我更新了我的问题