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