The following error occurs during continuous download today:
Can not findJava. Io. inputstream with the name [inputstream] in the invocation stack. Check the <Param name = "inputname"> tag specified for this action.
I checked the data for half a day: I found that the path is incorrect.
Define four attributes in action.
/** Download file type */
Protected string contenttype;
/** Name of the downloaded file */
Protected string filename;
/** Input stream */
Protected inputstream;
/** Download file path */
Protected string inputpath;
Public inputstream getinputstream () // gets the input stream
{
Return servletactioncontext. getservletcontext (). getresourceasstream (inputpath );
}
Public String getfilename () // obtain the Chinese name
{
Try
{
Return new string (filename. getbytes ("GBK"), "ISO-8859-1 ");
} Catch (unsupportedencodingexception E)
{
E. printstacktrace ();
Return filename;
}
}
Inputpath = "/" your documents are saved. Please refer to the document name. Doc ";
The configuration file in XML is as follows:
<Result name = "down" type = "stream">
<Param name = "contenttype"> application/octet-stream; charset = ISO8859-1 </param>
<Param name = "inputname"> inputstream </param>
<Param name = "buffersize"> 4096 </param>
<Param name = "contentdisposition"> attachment; filename = "$ {filename}" </param>
</Result>
<! -- Dynamic file download, do not know the future file type in advance, then we can set its value to: Application/octet-stream; charset = ISO8859-1, be sure to add charset, otherwise, the downloaded file may fail. -->