博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Springboot项目上传文件大小限制问题
阅读量:4697 次
发布时间:2019-06-09

本文共 1363 字,大约阅读时间需要 4 分钟。

最近项目中用到了文件图片上传操作,

前端 使用<input type="file" class="ignore" accept="image/jpeg,image/png,image/gif">  (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] with root causejava.lang.IllegalStateException: The multi-part request contained parameter data (excluding uploaded files) that exceeded the limit for maxPostSize set on the associated connector

 经过分析发现是springboot中的内置tomcat服务器限定了Httppost的最大size

通过在properties中添加如下配置,修改该内置服务器的对HttpPost数据的大小; 成功解决该问题;

server.maxHttpHeaderSize=102400000   //设定HttpHeader请求头大小 server.maxHttpPostSize =102400000   //设定Httppost数据大小

转载于:https://www.cnblogs.com/AnXinliang/p/9154659.html

你可能感兴趣的文章
bootstrap模态框和select2合用时input无法获取焦点(转)
查看>>
MockObject
查看>>
Chukwa
查看>>
(转)Maven仓库——私服介绍
查看>>
设计模式之工厂模式
查看>>
仿复制粘贴功能,长按弹出tips的实现
查看>>
Kubernetes-Host网络模式应用
查看>>
第三次作业
查看>>
sqlplus terminators - Semicolumn (;), slash (/) and a blank line
查看>>
省选知识清单/计划列表(咕?)
查看>>
远程桌面(3389)复制(拖动)文件
查看>>
转 lucene3搜索引擎,索引建立搜索排序分页高亮显示, IKAnalyzer分词
查看>>
win10应用UserControl
查看>>
BZOJ4516: [Sdoi2016]生成魔咒(后缀自动机)
查看>>
查看手机已经记住的WIFI密码
查看>>
最新版IntelliJ IDEA2019 破解教程(2019.08.07-情人节更新)
查看>>
C# 两个datatable中的数据快速比较返回交集或差集
查看>>
关于oracle样例数据库emp、dept、salgrade的mysql脚本复杂查询分析
查看>>
adb shell am 的用法
查看>>
实现自动点击
查看>>