Struts2文件上傳時的maxSize和maximumSize的區別與聯繫

Struts2上傳文件默認大小是2M,超過則報錯。解決辦法是在struts.xml中配置:java

<struts>spa

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

</struts>xml

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

而fileUpload攔截器裏的maximumSize指的則是單個文件的上傳大小。若是在maximumSize裏指定了1M的大小,在maxSize裏指定了10M的大小,你就能夠一次性上傳10個1M大小的文件。
ip

具體講解參見:http://stackoverflow.com/questions/4821334/limit-struts2-file-upload-max-size-without-uploading-the-whole-fileit

    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.io

相關文章
相關標籤/搜索