Struts中the request was rejected because its size (***) exceeds the configured ma
来源:互联网 发布:剑三正太帅气捏脸数据 编辑:程序博客网 时间:2024/05/26 09:53
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
修改这个大小。
出现错误的原因:
因为在利用struts中在上传文件的时候,struts的jar包(commons-fileupload)中默认了文件上传的最大值是2097152.所以当你传的文件大小大于这个值的时候就出现了这个错误!
解决办法!
1,我们可以在action中直接重写ActionSupport的addActionError()方法
- 1.public void addActionError(String anErrorMessage) {
- 2.
- 3.//这里要先判断一下,是我们要替换的错误,才处理
- 4.
- 5. if (anErrorMessage.startsWith("the request was rejected because its size")) {
- 6.
- 7. Matcher m = Pattern.compile("//d+").matcher(anErrorMessage);
- 8.
- 9. String s1 = "";
- 10.
- 11. if (m.find()) s1 = m.group();
- 12.
- 13. String s2 = "";
- 14.
- 15. if (m.find()) s2 = m.group();
- 16.
- 17. //偷梁换柱,将信息替换掉
- 18. super.addActionError("你上传的文件大小(" + s1 + ")超过允许的大小(" + s2 + ")");
- 19. //也可以改为在Field级别的错误
- 20. // super.addFieldError("file","你上传的文件大小(" + s1 + ")超过允许的大小(" + s2 + ")");
- 21.
- 22. } else {//否则按原来的方法处理
- 23.
- 24. super.addActionError(anErrorMessage);
- 25.}
这样上传不会出现异常,但是还是没有上传成功!
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
修改这个大小。
- Struts中the request was rejected because its size (***) exceeds the configured ma
- Struts中the request was rejected because its size (***) exceeds the configured ma
- struts2出现 the request was rejected because its size (XXXX) exceeds the configured maximum (XXXX)
- the request was rejected because its size (4652587) exceeds the configured maximum (2097152)
- the request was rejected because its size (***) exceeds the configured maximum (2097152) 上传不成功
- struts2出现 the request was rejected because its size (XXXX) exceeds the configured maximum (XXXX)
- 浅谈对struts2.2 the request was rejected because its size (XXXX) exceeds the configured maximum (XXXX)错
- org.apache.commons.fileupload.FileUploadBase$UnknownSizeException: the request was rejected because its size is unknown
- the request was rejected
- the request was rejected because no multipart boundary was found??求解
- XHR异步上传文件报错: “the request was rejected because no multipart boundary was found”
- The X11 forwarding request was rejected!
- The X11 forwarding request was rejected!
- The X11 forwarding request was rejected!
- The X11 forwarding request was rejected!
- xmanager - xstart - The X11 forwarding request was rejected
- AS项目运行正常,但查看代码飘红the file size exceeds configured limit.
- 【git】updates were rejected because the tip of your current branch is behind its remote counterpart
- poj3041 Asteroids 二分图最小点集覆盖
- 在MFC中使Edit Control自动滚动到最底端
- cSparrowApp类以及IO事件处理
- myeclipse不编译解决方法
- 关于QT的pro文件编写及英文文档
- Struts中the request was rejected because its size (***) exceeds the configured ma
- 统计一串字符串中出现次数最多和次多的单词(华为上机考试题)
- 我看易信
- sftp报Received message too long 1114795883
- 8583报文详细分析
- 统计一个字符串中各个英文单词的出现的频数
- ActivityThread运行框架
- TCP/IP模型
- poj 3974