zoukankan      html  css  js  c++  java
  • 上传文件过大的问题FileUploadBase$SizeLimitExceededException

    FileUploadBase$SizeLimitExceededException: the request was rejected because its size ..exc

    在上传94M的视频出现异常如下:

    [@APPNAME@] ERROR [http-80-3] MultiPartRequest.parse(130) | org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (102147245) exceeds the configured maximum (50097152)
    [@APPNAME@] ERROR [http-80-3] FileUploadInterceptor.intercept(227) | the request was rejected because its size (102147245) exceeds the configured maximum (50097152)
     

    解析:这个最大值是在struts2的源文件“struts2-core-2.0.11.1.jarorgapachestruts default.properties”中的struts.multipart.maxSize=2097152语句,如果想改大的话,就重新设定它,有两种方法:

    一种是重写:struts.properties文件。

    二是在struts.xml中加入常量来改变它如“ Java代码 
    <constant name="struts.multipart.maxSize" value="10000000" />

    当然了,也有struts2的拦截器可以限制文件的类型、大小等,但是当上传文件大小2M后,这个拦截器就不起作用了,只用小于2M(默认大小)的时候才起作用。那是因为:common-fileupload组件默认最大支持上传文件的大小为2M,当我们上传大于2M的文件时,就会出现上面所说的异常。是这个异常的发生导致了fileUpload拦截器没有机会执行,所以看到的是页面没有任何变化,也没有任何提示信息,只是在控制台打印出了上面的那些上传文件过大的异常。

    我解决问题的过程:

    刚开始只是在struts.xml文件最上部加入

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

    pt">但还是报同样的错误。


    接着查看struts.properties文件里的配置为:
    ### Load custom default resource bundles
    struts.custom.i18n.resources=MessageResource
    struts.multipart.maxSize=50097152
     
    ### character encoding
    struts.i18n.encoding=GBK
     
    修改为

    ### Load custom default resource bundles
    struts.custom.i18n.resources=MessageResource
    struts.multipart.maxSize=1000000000
     
    ### character encoding
    struts.i18n.encoding=GBK

    问题就解决了

     
  • 相关阅读:
    DataGrip中执行ORACL语句块进行代码测试
    ORACLE存储过程中使用SELECT INOT语句避免NO_DATA_FOUND的方法
    Pandas和numpy如何显示全部数据
    qrcodejs2+html2canvas生产二维码海报vue
    SQL多表查询
    行者app定位不准的问题分析
    Gdb printer打印STL
    Linux中的文件和目录结构详解
    Linux 文件的路径以及管理
    linux创建ftp服务
  • 原文地址:https://www.cnblogs.com/xhqgogogo/p/3262840.html
Copyright © 2011-2022 走看看