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 ""; }