diff --git a/README.md b/README.md index 7cc941ba..caf9d35a 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ pig 3. 不接受`功能请求`的 [issue](https://gitee.com/log4j/pig/issues),功能请求可能会被直接关闭。 -4. mail: pig4cloud@qq.com | QQ: 2270033969 +4. mail: pig4cloud@qq.com | QQ: 3130998334 #### 公开课 diff --git a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/exception/GlobalExceptionHandler.java b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/exception/GlobalExceptionHandler.java index 66020730..373f05ea 100755 --- a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/exception/GlobalExceptionHandler.java +++ b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/exception/GlobalExceptionHandler.java @@ -52,17 +52,29 @@ public class GlobalExceptionHandler { } /** - * validation Exception + * validation Exception (以json形式传参) * * @param exception * @return R */ - @ExceptionHandler({MethodArgumentNotValidException.class, BindException.class}) + @ExceptionHandler({MethodArgumentNotValidException.class}) @ResponseStatus(HttpStatus.BAD_REQUEST) public R bodyValidExceptionHandler(MethodArgumentNotValidException exception) { List fieldErrors = exception.getBindingResult().getFieldErrors(); log.warn(fieldErrors.get(0).getDefaultMessage()); return R.failed(fieldErrors.get(0).getDefaultMessage()); } - + /** + * validation Exception (以form-data形式传参) + * + * @param exception + * @return R + */ + @ExceptionHandler({BindException.class}) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public R bindExceptionHandler(BindException exception) { + List fieldErrors = exception.getBindingResult().getFieldErrors(); + log.warn(fieldErrors.get(0).getDefaultMessage()); + return R.failed(fieldErrors.get(0).getDefaultMessage()); + } }