如何更改要下载的文件名 [英] How to change the file name to be downloaded

查看:216
本文介绍了如何更改要下载的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是结果:

<result name="success" type="stream">
   <param name="contentDisposition">attachment;filename="${fileName}"</param>
</result>

现在如何工作:if fileName raghu.txt在DB中,它将下载为 raghu.txt

How it works now: if my fileName is "raghu.txt" in DB it will be downloaded as raghu.txt

我想要的:不管 fileName 的输出名称应该是 ravi.txt / p>

What I want: regardless of fileName the output name should be ravi.txt.

推荐答案

尝试您的行动

public String getFileName() {
  return "ravi.txt";
}

执行结果时,将通过此方法获取动态参数,将返回所需的值。但是,它只是告诉你动态参数是如何工作的,实际上如果配置使用动态参数你应该修改动作代码和 setFileName(ravi.txt); 之前将返回结果代码。然后你可以保持正常的吸气剂。

When result is executed it will get the dynamic parameter via this method, and it will return the value wanted. But, it's only to show you how dynamic parameters work, actually if the configuration used the dynamic parameter you should modify the action code and setFileName("ravi.txt"); before the result code is returned. Then you can remain the normal getter.

这篇关于如何更改要下载的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆