From 4d7a70671197f2c56cf65b64fbeb6a2f1b76ed35 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 14 Nov 2025 18:29:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=9D=E5=A4=96=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/czg/exception/CzgControllerAdvice.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cash-common/cash-common-api-config/src/main/java/com/czg/exception/CzgControllerAdvice.java b/cash-common/cash-common-api-config/src/main/java/com/czg/exception/CzgControllerAdvice.java index 8d6b28104..66b40dd16 100644 --- a/cash-common/cash-common-api-config/src/main/java/com/czg/exception/CzgControllerAdvice.java +++ b/cash-common/cash-common-api-config/src/main/java/com/czg/exception/CzgControllerAdvice.java @@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; import org.springframework.web.servlet.resource.NoResourceFoundException; import java.util.List; @@ -78,6 +79,14 @@ public class CzgControllerAdvice { return CzgResult.failure(CzgRespCode.PARAM_ERROR.getCode(), message); } + @ExceptionHandler(value = MethodArgumentTypeMismatchException.class) + public CzgResult methodArgumentTypeMismatchException(MethodArgumentTypeMismatchException ex) { + log.error("参数类型转换异常:{}", ex.getMessage()); + return CzgResult.failure(CzgRespCode.PARAM_ERROR.getCode(), ex.getMessage()); + } + + + /** * 处理自定义异常 */