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.