What does the @Valid annotation indicate in Spring?

前端 未结 8 1524
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 20:38

In the following example, the ScriptFile parameter is marked with an @Valid annotation.

What does @Valid annotation do?

<
8条回答
  •  情歌与酒
    2020-12-04 21:21

    Just adding to the above answer, In a web application @valid is used where the bean to be validated is also annotated with validation annotations e.g. @NotNull, @Email(hibernate annotation) so when while getting input from user the values can be validated and binding result will have the validation results. bindingResult.hasErrors() will tell if any validation failed.

提交回复
热议问题