The field headerImage exceeds its maximum permitted size of 1048576 bytes

蔚落 2023-07-14 08:08 71阅读 0赞

welcome to my blog

使用spring内置tomcat服务器上传文件失败, 报错如下, 因为默认文件大小上限为1MB

  1. 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
  2. [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is
  3. org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is java.lang.IllegalStateException:
  4. org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field headerImage exceeds its maximum permitted size of
  5. 1048576 bytes.] with root cause
  6. org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException:
  7. The field headerImage exceeds its maximum permitted size of 1048576 bytes.

解决方法: 在application.properties中加入以下两句即可

  1. # 上传单个文件的最大值为10MB
  2. spring.servlet.multipart.max-file-size=10MB
  3. # 单次请求中, 上传的所有文件总大小最大为10MB
  4. spring.servlet.multipart.max-request-size=10MB

发表评论

表情:
评论列表 (有 0 条评论,71人围观)

还没有评论,来说两句吧...

相关阅读