16

I'm having quite some trouble since I migrated my controllers from classical inheritance to use the annotations like @Controller and @RequestMapping. The problem is that I don't know how to plug in validation like in the old case. Are there any good tutorials about this?

matt b
  • 138,234
  • 66
  • 282
  • 345
cdecker
  • 4,515
  • 8
  • 46
  • 75
  • This is nice article on this topic: http://blog.jteam.nl/2009/08/04/bean-validation-integrating-jsr-303-with-spring/ – dma_k Jun 15 '11 at 09:06

3 Answers3

16

Have a look at §13.11.x of the Spring MVC documentation. It covers annotation-based controller configuration, including data binding. It should be very useful to you.

Good luck!

Sarel Botha
  • 12,419
  • 7
  • 54
  • 59
yawmark
  • 1,934
  • 14
  • 16
5

Spring 3 includes improved support for validation, and in particular, JSR-303 validation. You can validate form beans using the @Valid annotation and . See

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/validation.html#validation-beanvalidation

section 5.7.

Sarel Botha
  • 12,419
  • 7
  • 54
  • 59
3

At a pinch, there's always this thing: http://annovalidator.sourceforge.net/ - it's all tooled around using annotations for validation, and is designed to work with Spring.