How do I use @Valid with Spring MVC's @RequestBody parameters?

前端 未结 2 1607
孤城傲影
孤城傲影 2020-12-31 01:14

I\'m having an issue with using @Valid on a parameter to a handler method on my @Controller. My code looks like this:

@RequestMappi         


        
2条回答
  •  隐瞒了意图╮
    2020-12-31 01:51

    This is an issue in spring 3.0 and it is fixed in 3.1 M2.

    https://jira.springsource.org/browse/SPR-6709

    If you are using spring 3.0, based on some threads and extensive reading, here is the best approach for this problem. An aspect oriented approach so that we can back out when you upgrade it to the version of spring which fixes this issue.

    An aspect which intercepts calls to method which uses @RequestMapping annotation and for each parameter which has @Valid annotation on it, call the corresponding validator in the aspect.

提交回复
热议问题