Tag:java
Article From:https://segmentfault.com/q/1010000012149060
Question:

By default, I only need the message error message that I set up.

Is there any way?? Can’t find it all the time

Answer 0:

Resolved: capture abnormal information by formatting output by capturing MethodArgumentNotValidException exception.

Or using BindingResult can also be used

Answer 1:

You can refer to it

        Set<ConstraintViolation<Object>> results = validator.validate(obj);
        for (ConstraintViolation<Object> result : results) {
            System.out.println(result.getPropertyPath().toString());//attributeSystem.out.println (result.getMessage ()); / / error message}

Leave a Reply

Your email address will not be published. Required fields are marked *