美文网首页
Spring boot 上传文件大小限制

Spring boot 上传文件大小限制

作者: 金刚_30bf | 来源:发表于2018-10-23 09:03 被阅读0次

    版本 : 2.0.6

    当上传大文件时, 报错如下:

    2018-10-22 21:42:59.975 [XNIO-2 task-3] ERROR io.undertow.request - UT005023: Exception handling request to /batchupload
    java.lang.IllegalStateException: io.undertow.server.handlers.form.MultiPartParserDefinition$FileTooLargeException: UT000054: The maximum size 1048576 for an individual file in a multipart request was exceeded
        at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:794)
    
    

    spring boot中设置有参数 来这是上传文件大小
    类为:

    @ConfigurationProperties(prefix = "spring.servlet.multipart", ignoreUnknownFields = false)
    public class MultipartProperties {
    
        /**
         * Whether to enable support of multipart uploads.
         */
        private boolean enabled = true;
    
        /**
         * Intermediate location of uploaded files.
         */
        private String location;
    
        /**
         * Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or
         * kilobytes, respectively.
         */
        private String maxFileSize = "1MB";
    
        /**
         * Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or
         * kilobytes, respectively.
         */
        private String maxRequestSize = "10MB";
    

    在application.yml中设置 :

    spring:
      servlet:
        multipart:
          maxFileSize: "1000MB"
          maxRequestSize: "10000MB"
    

    相关文章

      网友评论

          本文标题:Spring boot 上传文件大小限制

          本文链接:https://www.haomeiwen.com/subject/zeynzftx.html