Struts中the request was rejected because its size (***) exceeds the configured ma
Struts中the request was rejected because its size (***) exceeds the configured maximum (2097152)
出现错误的原因:
因为在利用struts中在上传文件的时候,struts的jar包(commons-fileupload)中默认了文件上传的最大值是2097152.所以当你传的文件大小大于这个值的时候就出现了这个错误!
解决办法!
1,我们可以在action中直接重写ActionSupport的addActionError()方法
这样上传不会出现异常,但是还是没有上传成功!
2.修改上传的最大上限
<interceptor-ref name="fileUpload">
<param name="maximumSize">1000000</param>
</interceptor-ref>
和上面的方法不一样的是:这个方法不是去除异常,而是在你自己设定的范围内不会出现异常!
最新解决方案是在struts.xml中设置
<constant name="struts.multipart.maxSize" value="100000000"/>
或者sturts的核心包中找到
default.properties中我们可以看到如下片段:
struts.multipart.maxSize=2097152
修改这个大小。