JSR-303 bean validation with Spring does not kick in

后端 未结 2 2016
夕颜
夕颜 2020-12-18 05:45

I\'ve configured a JSR-303 custom validator following what\'s given in the docs (http://docs.spring.io/spring/docs/4.0.x/spring-framework-reference/html/validation.html), co

2条回答
  •  天涯浪人
    2020-12-18 06:43

    For spring to validation to kick in the blend argument needs a @Valid annotation in front of it.

    Your approach might not work since parameter contraints are not supported by the JSR303.

    Constraint annotations can target any of the following ElementTypes:

    FIELD for constrained attributes

    METHOD for constrained getters

    TYPE for constrained beans

    ANNOTATION_TYPE for constraints composing other constraints

    http://beanvalidation.org/1.0/spec/#constraintsdefinitionimplementation

提交回复
热议问题