From c124157c65c36c058260b56b923b4386560851a0 Mon Sep 17 00:00:00 2001 From: "382696293@qq.com" <382696293@qq.com> Date: Fri, 26 Jan 2024 14:42:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=BF=87=E5=A4=A7=E7=9A=84?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E7=A0=81=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/handler/GlobalExceptionHandler.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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()); + } + /** * 内部认证异常 */