纪录:springboot配置文件上传大小失效问题

本文记录了Springboot项目中遇到的文件上传大小限制问题。当上传文件超过1.5MB时,抛出MultipartException。原因是Springboot内置Tomcat服务器对HttpPost数据的大小有限制。通过在properties配置文件中增加`server.maxHttpHeaderSize`和`server.maxHttpPostSize`设置,可以调整此限制,从而解决问题。
摘要由CSDN通过智能技术生成

Springboot项目上传文件大小限制问题
最近项目中用到了文件图片上传操作,

前端 使用 (base64字节)

后台使用String字符串进行接收(base64字节)

properties配置文件中进行文件上传大小配置

spring.http.multipart.max-file-size=20Mb //上传文件的大小限定;只有上传采用文件格式进行接收时起作用,针对上面的base64格式图片(后台是String进行接收)不起作用;
spring.http.multipart.max-request-size=60Mb //上传请求数据的大小限定;限定请求的总数据大小

但是发现当上传文件大小大于1.5M时就会报错:
2018-06-08 11:03:19.006 ERROR 3784 — [nio-8080-exec-8] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: The multi-part request contained parameter data (excluding uploaded files) that exceeded the limit for maxPostSize set on the associated connector] wit

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值