Spring boot fileuploadException

在前端上传大小超过1M的文件时,报了个异常。

 

 

 

 

后来发现是spring boot有默认的上传文件大小限制。为1M,对应属性为multipart.maxFileSize。在配置文件里增加如下配置即可:

 

需要设置以下两个参数

multipart.maxFileSize
multipart.maxRequestSize

application.yml中设置如下

multipart:
  maxFileSize: 10485760
  maxRequestSize: 10485760

 

application.properties中设置如下:

Spring Boot 1.3.x 或者之前

multipart.maxFileSize=100Mb
multipart.maxRequestSize=1000Mb

Spring Boot 1.4.x 或者之后

spring.http.multipart.maxFileSize=100Mb
spring.http.multipart.maxRequestSize=1000Mb

很多人设置了multipart.maxFileSize但是不起作用,是因为1.4版本以上的配置改了,详见官方文档:spring boot 1.4

转载于:https://my.oschina.net/martinwu/blog/876267

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值