spring boot配置对上传文件的大小限制
spring-boot 2.0之前
Spring Boot1.4版本后配置更改为(默认单个文件最大1Mb,单次请求文件总数大小最大10Mb):
spring.http.multipart.maxFileSize = 20MB
spring.http.multipart.maxRequestSize=20MB
spring-boot 2.0之后:
Spring Boot2.0之后的版本配置修改为(默认单个文件最大1Mb,单次请求文件总数大小最大10Mb):
spring.servlet.multipart.max-file-size = 20MB
spring.servlet.multipart.max-request-size=20MB
超过20Mb,就会报错,如下:
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (25766453) exceeds the configured maximum (20971520)
还有其他一些配置,都是spring.http.改为spring.servlet.
1.启动报错:
APPLICATION FAILED TO START
Description

最低0.47元/天 解锁文章
1248

被折叠的 条评论
为什么被折叠?



