@ Valid annotation, how to control the order of object validation

public JsonResult add(@Valid Person person, BindingResult bindingResult) {
    // bindingResult.getAllErrors()
    // :;;
    // 
}

1, or manually verify, controllable
2, spring uses hibernate-validator, he supports a way called grouping, but there are a lot of changes, not elegant.
you can take a look at the link description


you can sort it yourself, traverse it with bindingResult.getFieldErrors, or use bindingResult.getAllErrors () and convert it to FieldError (if you can), and then sort it yourself by field.

Menu