The field headerImage exceeds its maximum permitted size of 1048576 bytes
原创
©著作权归作者所有:来自51CTO博客作者littlehaes的原创作品,请联系作者获取转载授权,否则将追究法律责任
使用spring内置tomcat服务器上传文件失败, 报错如下, 因为默认文件大小上限为1MB
2020-03-13 20:10:36,758 ERROR [http-nio-8081-exec-7] o.a.c.c.C.[.[.[.[dispatcherServlet] [DirectJDKLog.java:175] Servlet.service() for servlet
[dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is java.lang.IllegalStateException:
org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field headerImage exceeds its maximum permitted size of
1048576 bytes.] with root cause
org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException:
The field headerImage exceeds its maximum permitted size of 1048576 bytes.
解决方法: 在application.properties中加入以下两句即可
# 上传单个文件的最大值为10MB
spring.servlet.multipart.max-file-size=10MB
# 单次请求中, 上传的所有文件总大小最大为10MB
spring.servlet.multipart.max-request-size=10MB