From 83f5627b41f4e7662940e2b4c40a58817859fd0b Mon Sep 17 00:00:00 2001 From: dqjdda <201507802@qq.com> Date: Thu, 31 Oct 2019 11:49:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zhengjie/exception/handler/GlobalExceptionHandler.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java b/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java index 3815ea40..2d0385b9 100644 --- a/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java +++ b/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java @@ -80,7 +80,10 @@ public class GlobalExceptionHandler { // 打印堆栈信息 log.error(ThrowableUtil.getStackTrace(e)); String[] str = Objects.requireNonNull(e.getBindingResult().getAllErrors().get(0).getCodes())[1].split("\\."); - String message = str[1] + ":" + e.getBindingResult().getAllErrors().get(0).getDefaultMessage(); + String message = e.getBindingResult().getAllErrors().get(0).getDefaultMessage(); + if("不能为空".equals(message)){ + message = str[1] + ":" + message; + } return buildResponseEntity(ApiError.error(message)); }