Can not find a java. Io. inputstream with the name [downloadfile] in the invocation stack.
If the preceding exceptions occur, there are usually two situations.
One is that the method for getting the file stream in the action does not match the one configured later,
Public inputstream getdownloadfile
(){},
(Is the first letter lower case after get consistent with the configuration parameters in struts)
<Param name = "inputname"> downloadfile
</Param>
Troubleshoot this situation
The second is caused by Chinese garbled characters.
In the request sent from the front-end, the download file name is Chinese and garbled characters are obtained in the background. All files cannot be found when the input stream is obtained,
Getdownloadfile () returns NULL, which will prompt you
Can not find a java. Io. inputstream with the name [downloadfile] in
Invocation stack.
The solution is to obtain and decode the file name in the request parameters.
Public void setfilename (string filename ){
String fname = servletactioncontext. getrequest (). getparameter ("FILENAME ");
Try {
/*
* UTF-8 decoding of the fname parameter, note: the actual UTF-8 decoding will use local encoding, the local is GBK.
* The request. setcharacterencoding decoding is invalid.
* Only the getdownloadfile () method can be decoded to find the requested file in the download directory.
**/
Fname = new string (fname. getbytes ("ISO-8859-1"), "UTF-8 ");
} Catch (exception e ){
E. printstacktrace ();
}
This. filename = fname;
}
Can be downloaded normally