I've been trying to implement an action which allows the user to download a file with a specific filename. This filename
is set by passing the action a parameter through struts.xml
this way:
<result name="success" type="stream">
<param name="contentType">application/octet-stream</param>
<param name="inputName">input_document</param>
<param name="contentDisposition">attachment;filename=foo.bar</param>
<param name="bufferSize">1024</param>
</result>
I have omitted the rest of the code as I just want to focus on this:
<param name="contentDisposition">attachment;filename=foo.bar</param>
That way it works perfectly and lets you download the foo
file with .bar
extension.
So here's the deal, I was curious to know wether if is it possible to retrieve the extension from a properties file and pass it through the parameter, for example, like this:
<param name="contentDisposition">attachment;filename=foo%{+ getText("EXTENSION_KEY_IN_PROPERTIES_FILE")}</param>
I know that getText("...")
won't work but I just want you to understand what I'm searching for.
I'm currently working with some properties files for global parameters and localization stuff so it would be great if I could retrieve this file extension from one of them.
It should work if your action implements TextProvider
<param name="contentDisposition">attachment;filename=foo${getText('EXTENSION_KEY_IN_PROPERTIES_FILE')}</param>