Add configuration in application.properties :
spring.http.multipart.maxFileSize=50Mb spring.http.multipart.maxRequestSize=50Mb
Control the size of the file submitted by the web, if the size exceeds, the request will not go to the background
@Bean(name = "multipartResolver") public MultipartResolver multipartResolver() { CommonsMultipartResolver resolver = new CommonsMultipartResolver(); resolver.setDefaultEncoding("UTF-8"); resolver.setResolveLazily(true); resolve.setMaxInMemorySize(40960); resolver.setMaxUploadSize(10 * 1024 * 1024);// upload file size 10M 10*1024*1024 return resolver; }
Control file size filtering from code.