cdecker
cdecker

Reputation: 4687

Spring MVC validation with Annotations

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?

Upvotes: 16

Views: 31719

Answers (3)

user41871
user41871

Reputation:

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.

Upvotes: 5

yawmark
yawmark

Reputation: 1944

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!

Upvotes: 16

Mike Norrish
Mike Norrish

Reputation: 31

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.

Upvotes: 3

Related Questions