springboot上传文件:the request was rejected because its size (11601865) exceeds the configured maximum

springboot上传文件时报错:

1
org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (11601865) exceeds the configured maximum (10485760)

由于上传的文件超过了默认上传文件的大小,springboot 默认 multipart.max-file-size大小是1M,max-request-size默认大小是10M。

解决方法:

在application.properties中配置:

如果是springboot1.x,使用如下配置:

1
2
spring.http.multipart.max-file-size=100MB
spring.http.multipart.max-request-size=100MB

如果是springboot2.x, 使用如下配置:

1
2
spring.servlet.multipart.max-file-size=100MB
spring.servlet.multipart.max-request-size=100MB

springboot上传文件:the request was rejected because its size (11601865) exceeds the configured maximum
https://river106.cn/posts/69cbeb1a.html
作者
river106
发布于
2020年3月15日
许可协议