Struts-File Download Code & error, struts-File Download Code

Source: Internet
Author: User

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

 

 

 

 

  

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.