package com.xdf.creative.config; import java.io.IOException; import com.xdf.creative.util.page.ApiResult; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.multipart.MaxUploadSizeExceededException; @RestControllerAdvice public class CustomExceptionHandler { @ExceptionHandler(MaxUploadSizeExceededException.class) public ApiResult uploadException(MaxUploadSizeExceededException e) throws IOException { return ApiResult.fail("最大上传文件为1M,上传文件大小超出限制!"); } }