You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shuai Zheng <zh...@gmail.com> on 2007/03/28 09:02:24 UTC
How to configure result in the code
Dear All,
What I want to do is read the files from database and let the user to
download them.
In the showcase example, I find the following configuration:
<action name="download2" class="
org.apache.struts2.showcase.filedownload.FileDownloadAction">
<param name="inputPath">\images\struts-gif.zip</param>
<result name="success" type="stream">
<param name="contentType">application/zip</param>
<param name="inputName">inputStream</param>
<param name="contentDisposition">filename="struts-gif.zip
"</param>
<param name="bufferSize">4096</param>
</result>
</action>
But I may not know the filename, contentType, etc (because these files are
uploaded by the user).
Do anybody can tell me how to get the handler of result in the code so I can
set all these information?
Thanks very much,
Regards,
Zheng Shuai
Re: How to configure result in the code
Posted by Dale Newfield <Da...@Newfield.org>.
Shuai Zheng wrote:
> But I may not know the filename, contentType, etc (because these files are
> uploaded by the user).
http://struts.apache.org/2.0.6/struts2-core/apidocs/org/apache/struts2/dispatcher/StrutsResultSupport.html
http://struts.apache.org/2.0.6/struts2-core/apidocs/com/opensymphony/xwork2/util/TextParseUtil.html#translateVariables(java.lang.String,%20com.opensymphony.xwork2.util.ValueStack)
<action name="download2" class="
org.apache.struts2.showcase.filedownload.FileDownloadAction">
<result name="success" type="stream">
<param name="contentType">${dbFile.contentType}</param>
<param name="contentLength">${dbFile.contentLength}</param>
<param name="inputName">inputStream</param>
<param name="contentDisposition">filename="${dbFile.filename}"</param>
<param name="parse">true</param>
</result>
</action>
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org