文件上传失败
- 前端报错 net::ERR_CONNECTION_RESET
- 后端报错 org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException: the request was rejected because its size (xxxxxx) exceeds the configured maximum (xxxxxx)
解决方案
- 配置文件
application.yml
代码语言:javascript
复制spring:
servlet:
multipart:
max-file-size: 100MB
max-request-size: 200MB
- JAVA配置
代码语言:javascript
复制@Bean
public MultipartConfigElement multipartConfigElement() {
long maxFileSize = 100l;
long maxRequestSize = 200l;
MultipartConfigFactory factory = new MultipartConfigFactory();
factory.setMaxFileSize(DataSize.of(maxFileSize ,MEGABYTES));
factory.setMaxRequestSize(DataSize.of(maxRequestSize ,MEGABYTES));
return factory.createMultipartConfig();
}