Struts-File Download Code & error, struts-File Download Code
Struts code for File Download
Configure the struts. xml file
Create Action class
Jsp code
Possible Errors During running !!!!!
1. The downloaded file name is displayed as xxx. action or is not the original file name.
It may be that the getFileName method for obtaining the file name is not capitalized.
It may be that the getFileName method directly returns filename without encoding.
2. Run the downloaded file code and report "Can not find a java. io. inputStream with the name [InputStream] in the invocation stack. check the <param name = "inputName"> tag specified for this action. "Exception
If the file to be downloaded is stored in the called path
ServletActionContext. getServletContext (). getResourceAsStream (realPath)
If the obtained value is null, the following situations may occur:
Incorrect file name
No method for configuring the get file next to inputName to respond to the stream
The path is not correctly written.
Create an external path when you need to download the file externally