开始只在struts.xml文件中加入以下配置

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

在index.jsp文件中加入的 <s:fielderror/>没有显示

只会在控制台打印错误信息:

警告: Request exceeded size limit!
org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (251842) exceeds the configured maximum (10000)

解决方法:

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

在拦截器中添加以下配置

    <interceptor-ref name="fileUpload">
                <param name="allowedTypes">image/png,image/jpeg</param>
                <param name="maximumSize">10000</param> <!--此处的值应小于常量中设置的最大值-->
            </interceptor-ref>
            <!-- 默认的拦截器栈 -->
            <interceptor-ref name="defaultStack"/>

结果如下:

将<param name="maximumSize">10000</param>中的值设置大一些则该大小文件能正常上传。

说明:根据struts源码/org/apache/struts2/struts-messages.properties

该文件中的此段可得上述结论

struts.messages.bypass.request=Bypassing {0}/{1}
struts.messages.current.file=File {0} {1} {2} {3}
struts.messages.invalid.file=Could not find a Filename for {0}. Verify that a valid file was submitted.
struts.messages.invalid.content.type=Could not find a Content-Type for {0}. Verify that a valid file was submitted.
struts.messages.removing.file=Removing file {0} {1}
struts.messages.error.uploading=Error uploading: {0}
struts.messages.error.file.too.large=File {0} is too large to be uploaded. Maximum allowed size is {4} bytes!
struts.messages.error.content.type.not.allowed=Content-Type not allowed: {0} "{1}" "{2}" {3}
struts.messages.error.file.extension.not.allowed=File extension not allowed: {0} "{1}" "{2}" {3}

struts文件上传——文件过大时错误提示的配置问题说明的更多相关文章

  1. Struts Upload上传文件

    1.Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax.servlet.context.te ...

  2. 精讲RestTemplate第6篇-文件上传下载与大文件流式下载

    本文是精讲RestTemplate第6篇,前篇的blog访问地址如下: 精讲RestTemplate第1篇-在Spring或非Spring环境下如何使用 精讲RestTemplate第2篇-多种底层H ...

  3. django中处理文件上传文件

    1 template模版文件uploadfile.html 特别注意的是,只有当request方法是POST,且发送request的<form>有属性enctype="multi ...

  4. 【收集】JAVA多文件 上传文件接口代码 -兼容app

    原文:http://www.verydemo.com/demo_c143_i23854.html 我们在 multifile 中可以很容易的发现如何使用,这里就简单说说了,首先在页面上我们需要有这样几 ...

  5. MVC文件上传文件限制

    最近想实现MVC中文件上传限制,总觉得有便利的方法,找了半天就找到加属性accept <input type="file" id="file" name= ...

  6. Struts2框架下的文件上传文件类型、名称约定

    Struts2框架下的文件上传机制:1.通过multipart/form-data form提交文件到服务器2.文件名是通过什么地方设置的?在strust2的FileUploadInterceptor ...

  7. java http下载文件/上传文件保存

    private boolean downloadFile(String httpUrl, String savePath) { int byteread = 0; try { URL url = ne ...

  8. iOS文件上传文件URL错误Invalid parameter not satisfying: fileURL'

    一:iOS文件上传提示URL错误 Invalid parameter not satisfying: fileURL' 二:解决方法: NSString *imagePath = [[NSBundle ...

  9. springmvc文件上传,出现400 的错误问题

    遇见的原因是公司系统上的图片上传忽然不好使了,报错400.单独针对这个模块调了好长时间都没解决,后来才发现前几天做过一个excel上传导入的功能... 使用SptingMVC3.1.3 对于文件上传提 ...

随机推荐

  1. SSIS教程:创建简单的ETL包 -- 3. 添加日志(Adding Logging)

    Microsoft Integration Services 包含日志记录功能,可通过提供任务和容器事件跟踪监控包执行情况以及进行故障排除. 日志记录功能非常灵活,可以在包级别或在包中的各个任务和容器 ...

  2. iptables-linux(ls)-inode-block

    Part1:iptables 环境:centos6.7 目前我只配置了INPUT.OUTPUT和FORWORD都是ACCEPT的规则 由于想要先实现防火墙规则,所以前面的内容讲的是方法,后面是详解ip ...

  3. JS 浮点数计算

    一.从String中解析浮点数 parseFloat(string) 语法说明 parseFloat是个全局函数,不属于任何对象. parseFloat将它的字符串参数解析成为浮点数并返回.如果在解析 ...

  4. springMVC 静态资源加版本号

    springMVC 静态资源加版本号 http://blog.csdn.net/zhangt85/article/details/42126275

  5. java中程序上线报错: tomcat中java.lang.OutOfMemoryError: PermGen space

    在程序测试没问题之后,上线试运行,在运行的过程中某个功能一点击就报如下错,然后重启服务器就好了,一会又是如此,解决方法如下(亲测) PermGen space的全称是Permanent Generat ...

  6. vi 编辑器使用中常见的命令

    原创作品,转载请在文章头部(显眼位置)注明出处:https://www.cnblogs.com/sunshine5683/p/10014724.html 要在linux学习的路上越走越远,总结是必不可 ...

  7. hadoop fs -put localfile . 时出现如下错误: could only be replicated to 0 nodes, instead of 1

    hadoop fs -put localfile . 时出现如下错误:could only be replicated to 0 nodes, instead of 1网友的说法: 这个问题是由于没有 ...

  8. sublime Text3汉化和激活注册码

    sublimeText3 很不错,前面几天下了vscore学习Node.js,感觉有点懵,今天下载sublimeText3,遇到的一些小问题,在这里说说: 百度云:https://pan.baidu. ...

  9. Android踩坑随笔Fragment中onActivityResult方法不被调用

    最近项目里要做头像功能,参考了这篇博客(GitHub - zhudfly/SelectAvatarApplication: 一个选择并显示头像圆形控件,可以通过拍照或者选择相册中的图片来设置图片),但 ...

  10. MUI框架-04-切换页面头部文字重叠

    MUI框架-04-切换页面头部文字重叠 从现在开始就只分享 MUI 框架开发时遇到的问题了 开发不懂请查看:官方文档 问题情况 切换页面 title 文字重叠,覆盖 截图: 解决办法 给 h1 标签加 ...