Struts2文件上传时的maxSize和maximumSize的区别与联系

Struts2上传文件默认大小是2M,超过则报错。解决办法是在struts.xml中配置:

<struts>

    <constant name= "struts.multipart.maxSize" value= "10485760"></constant >

</struts>

<interceptor-ref name= "fileUpload">
          <param name ="maximumSize"> 2097152</ param>
</interceptor-ref >

而fileUpload拦截器里的maximumSize指的则是单个文件的上传大小。如果在maximumSize里指定了1M的大小,在maxSize里指定了10M的大小,你就可以一次性上传10个1M大小的文件。

具体讲解参见:http://stackoverflow.com/questions/4821334/limit-struts2-file-upload-max-size-without-uploading-the-whole-file

    There are two file size parameters one has to do with individual files sizes the other with the the maximum multi part file size. This is in place because you can receive an array of files if you wish (just change the setters type from File to File[], so easy), say struts.multipart.maxSize is set to 10MB and file size (maximumSize) is set to 1 MB you should be able to receive 10 1MB files. So the buffer should be allowed to grow to 10 MB.

你可能感兴趣的:(Struts2文件上传时的maxSize和maximumSize的区别与联系)