漂泊车手,角落娱乐社区,唐闻生
lz最近升级springboo框架到2.1.6,踩了一些坑,这里介绍的是文件上传大小限制。
#文件上传配置 1.5.9 spring: http: multipart: enabled: true max-file-size: 100mb max-request-size:100mb
##文件上传配置 2.x spring: servlet: multipart: enabled: true max-file-size: 100mb max-request-size: 100mb
我们可以从源码分析,找到springboot的相关源码——multipartproperties
类
package org.springframework.boot.autoconfigure.web.servlet; import javax.servlet.multipartconfigelement; import org.springframework.boot.context.properties.configurationproperties; import org.springframework.boot.web.servlet.multipartconfigfactory; import org.springframework.util.stringutils; @configurationproperties( prefix = "spring.servlet.multipart", ignoreunknownfields = false ) public class multipartproperties { private boolean enabled = true; private string location; private string maxfilesize = "1mb"; private string maxrequestsize = "10mb"; private string filesizethreshold = "0"; private boolean resolvelazily = false; ......... }
上面是springboot2.x源码,从上面可以看出,maxfilesize
,即最大文件大小,默认被限制为1mb,maxrequestsize
即最大请求大小,默认被限制为10mb。该类的注解中prefix
=spring.servlet.multipart。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
浅析我对 String、StringBuilder、StringBuffer 的理解
使用IDEA搭建SSM框架的详细教程(spring + springMVC +MyBatis)
Springboot整合freemarker 404问题解决方案
引入mybatis-plus报 Invalid bound statement错误问题的解决方法
网友评论