Example of file upload and download of struts 2 in Java

File upload

1. How many small problems to deal with?

1. The file name is duplicate. Generally, a UUID can be generated in front of the file name as a prefix.

2. Limit the size of a single file

3. Limit the type of document

4. Limit the size of the total file

2. The fileUpload interceptor is provided in struts 2 to set these attribute values for us

The fileUpload interceptor has three properties that can be set

Note: at org apache. Default. Under struts 2 There is a limit on the total size of uploaded files in properties You can use constants to modify this restriction struts multipart. maxSize=2097152

I Upload file related error messages?

1. Error messages related to file upload are displayed in struts messages Predefined in the properties file

2. You can upload the resource file corresponding to the action in the file or in I18N_ zh_ CN. Redefine the error message in the properties internationalization resource file

File download

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>