如何限制利用spring boot 框架自動限制上傳文件

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

@ExceptionHandler
public String handleMaxUploadSizeExceededException(MaxUploadSizeExceededException ex, NativeWebRequest request) {
if(ex instanceof org.springframework.web.multipart.MaxUploadSizeExceededException){
//    request.setAttribute("error", "文件超過長度");
request.setAttribute("error", "文件超過長度",112233);
}
return "";
}
相關文章
相關標籤/搜索