diff --git a/flossom-common/flossom-common-security/src/main/java/com/flossom/common/security/handler/GlobalExceptionHandler.java b/flossom-common/flossom-common-security/src/main/java/com/flossom/common/security/handler/GlobalExceptionHandler.java index 868cbb1..c95b554 100644 --- a/flossom-common/flossom-common-security/src/main/java/com/flossom/common/security/handler/GlobalExceptionHandler.java +++ b/flossom-common/flossom-common-security/src/main/java/com/flossom/common/security/handler/GlobalExceptionHandler.java @@ -18,6 +18,8 @@ import org.springframework.web.bind.MissingPathVariableException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; +import org.springframework.web.multipart.MaxUploadSizeExceededException; + import javax.servlet.http.HttpServletRequest; /** @@ -152,6 +154,16 @@ public class GlobalExceptionHandler return AjaxResult.error(message); } + /** + * 业务正常返回响应码,不是异常 + */ + @ExceptionHandler(MaxUploadSizeExceededException.class) + public AjaxResult handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e, HttpServletRequest request) + { + log.info(e.getMessage()); + return AjaxResult.error("文件过大!", e.getMessage()); + } + /** * 内部认证异常 */