no message
Showing
2 changed files
with
2 additions
and
11 deletions
| ... | @@ -5,8 +5,6 @@ package com.lego.core.annotation; | ... | @@ -5,8 +5,6 @@ package com.lego.core.annotation; |
| 5 | * @date 2025/4/23 | 5 | * @date 2025/4/23 |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | import com.lego.core.annotation.AtLeastOneNonNullValidator; | ||
| 9 | |||
| 10 | import javax.validation.Constraint; | 8 | import javax.validation.Constraint; |
| 11 | import javax.validation.Payload; | 9 | import javax.validation.Payload; |
| 12 | import java.lang.annotation.ElementType; | 10 | import java.lang.annotation.ElementType; | ... | ... |
| ... | @@ -25,7 +25,6 @@ import org.springframework.web.method.annotation.MethodArgumentTypeMismatchExcep | ... | @@ -25,7 +25,6 @@ import org.springframework.web.method.annotation.MethodArgumentTypeMismatchExcep |
| 25 | import javax.servlet.http.HttpServletRequest; | 25 | import javax.servlet.http.HttpServletRequest; |
| 26 | import javax.validation.ConstraintViolation; | 26 | import javax.validation.ConstraintViolation; |
| 27 | import javax.validation.ConstraintViolationException; | 27 | import javax.validation.ConstraintViolationException; |
| 28 | import java.util.Objects; | ||
| 29 | 28 | ||
| 30 | /** | 29 | /** |
| 31 | * 全局异常处理器 | 30 | * 全局异常处理器 |
| ... | @@ -187,14 +186,8 @@ public class GlobalExceptionHandler { | ... | @@ -187,14 +186,8 @@ public class GlobalExceptionHandler { |
| 187 | @ExceptionHandler(MethodArgumentNotValidException.class) | 186 | @ExceptionHandler(MethodArgumentNotValidException.class) |
| 188 | public R<Void> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { | 187 | public R<Void> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { |
| 189 | log.error(e.getMessage()); | 188 | log.error(e.getMessage()); |
| 190 | if(Objects.nonNull(e.getBindingResult().getFieldError())) { | 189 | String message = e.getBindingResult().getFieldError().getDefaultMessage(); |
| 191 | String message = e.getBindingResult().getFieldError().getDefaultMessage(); | 190 | return R.fail(message); |
| 192 | return R.fail(message); | ||
| 193 | } | ||
| 194 | else{ | ||
| 195 | String message = "2D和3D不能都为空"; | ||
| 196 | return R.fail(message); | ||
| 197 | } | ||
| 198 | } | 191 | } |
| 199 | 192 | ||
| 200 | /** | 193 | /** | ... | ... |
-
Please register or sign in to post a comment