Why can't I use Valid parameter along with RequestParam in Spring MVC?

前端 未结 3 1522
北海茫月
北海茫月 2020-12-16 19:06

Example:

public String getStudentResult(@RequestParam(value = \"regNo\", required = true) String regNo, ModelMap model){

How can I use @v

3条回答
  •  执念已碎
    2020-12-16 19:12

    @Valid can be used to validate beans. I have'nt seen it used on single string parameters. Also it requires a validator to be configured.

    The @Valid annotation is part of the standard JSR-303 Bean Validation API, and is not a Spring-specific construct. Spring MVC will validate a @Valid object after binding so-long as an appropriate Validator has been configured.

    Reference : http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html

提交回复
热议问题