You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Struts2 Fan <st...@gmail.com> on 2007/07/12 07:32:46 UTC
[S2] How to download a file from a hyperlink
Hi all,
I searched the archieves but couldn't find the answer for S2. I just want
the download a file from a hyperlink but the type is not important.
here is the part of the struts.xml
<action name="showFile" class="ShowFileAction">
<result name="success" type="stream">
???
inputStream
???
4096
</result>
</action>
In my action I return an inputStream.
public class ShowFileAction extends BaseAction{
public InputStream getInputStream() throws Exception {
// it works right because the images are shown clearly.
return new FileInputStream("/a.rar"); // or "b.exe"
}
public String execute() throws Exception {
return SUCCESS;
}
}
the hyperlink code is
/showFile.html?fileName=a.rar download
Any ideas?
--
View this message in context: http://www.nabble.com/-S2--How-to-download-a-file-from-a-hyperlink-tf4066181.html#a11553966
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org