更新时间:2023-09-02 16:50:34
您需要在application.properties文件中设置默认配置
You need to set a default configuration in application.properties file
spring.http.multipart.max-file-size=30MB
spring.http.multipart.max-request-size=30MB
在你的控制器中你需要抛出 MaxUploadSizeExceededException
基于文件大小的异常:
And in your controller you need to throw MaxUploadSizeExceededException
exception based on the file size :
long limit = 1024 * 1024 * 10;
if (file.getSize() > limit) {
throw new MaxUploadSizeExceededException(limit);
}