File Upload (4)

Source: Internet
Author: User

Extended File Upload

Set the File Upload format, size, and prompt information

1. Set the File Upload format and size to be configured in struts. xml. Use the struts interceptor fileupload, but be sure to add the default interceptor; otherwise, fileupload cannot be found.

<Action name = "Upload" class = "com. Test. Action. uploadaction">
<Result name = "success">/upload/uploadresult. jsp </result>
<Result name = "input">/upload. jsp </result>

<! -- Adds an interceptor to specify the maximum value of each uploaded file -->
<Interceptor-ref name = "fileupload">

<! -- Specify the size of the uploaded file -->
<Param name = "maximumsize"> 409600 </param>

<! -- Specify the upload file type -->
<Param name = "allowedtypes"> application/vnd. MS-PowerPoint </param>
</Interceptor-ref>

<Interceptor-ref name = "defaultstack"> </Interceptor-ref>
</Action>

 

2. Set the prompt information when uploading files, is according to the struts core package under the strust-messages.properties file, you can customize a global configuration file, reset the properties.

For example, to create a Global File message. properties under SRC, you must configure <constant name = "struts. Custom. i18n. Resources" value = "message"/> In struts. xml.

 

If you set the file too large prompt information, you need to change the attribute struts. Messages. Error. file. Too. Large, specific to view the strust-messages.properties file.

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.