SpringBoot web上传文件大小限制

SpringBoot web默认上传文件的大小限制为1MB,超过会报

Caused by: java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.
	at org.apache.catalina.connector.Request.parseParts(Request.java:2939)
	at org.apache.catalina.connector.Request.getParts(Request.java:2797)
	at org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:1098)
	at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:95)
	... 43 more

解决办法,在controller的配置文件添加

spring:
   servlet:
    multipart:
      max-file-size: 50MB #单个文件的大小限制
      max-request-size: 50MB #单次请求的大小限制

你可能感兴趣的:(spring,boot,前端,java)