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()); + } + + + /** * 处理自定义异常 */