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

戏子无情 提交于 2019-11-30 08:13:34

Are you using Spring 3.1? It is a newly added feature in Spring version 3.1. Please see Validation For @RequestBody Method Arguments

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!