如何限制利用spring boot 框架自动限制上传文件

spring:
  application:
    name: appname
  servlet:
    multipart:
      enabled: true
      max-file-size: 512MB
      max-request-size: 512MB

@ExceptionHandler
public String handleMaxUploadSizeExceededException(MaxUploadSizeExceededException ex, NativeWebRequest request) {
if(ex instanceof org.springframework.web.multipart.MaxUploadSizeExceededException){
//    request.setAttribute("error", "文件超过长度");
request.setAttribute("error", "文件超过长度",112233);
}
return "";
}
原文地址:https://www.cnblogs.com/wzihan/p/12918784.html