东方网 文促会 后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CustomExceptionHandler.java 630B

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