Hibernate Validator. How to work with @Valid annotation?

前端 未结 2 1196
梦如初夏
梦如初夏 2021-02-15 17:12

What purpose of @Valid annotation when putting it on method parameter level?

public void (@Valid Person p) { ... }

I created a te

2条回答
  •  说谎
    说谎 (楼主)
    2021-02-15 17:39

    Its purpose is to validate the object against the defined constraints.

    From Hibernate Docs

    Performs validation recursively on the associated object. If the object is a collection or an array, the elements are validated recursively. If the object is a map, the value elements are validated recursively.

    This might help http://www.mkyong.com/spring-mvc/spring-3-mvc-and-jsr303-valid-example/

提交回复
热议问题