Spring boot 上传文件大小限制

2018-10-23  本文已影响0人  金刚_30bf

版本 : 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"
上一篇下一篇

猜你喜欢

热点阅读