views:

54

answers:

2

I know the Commons Validator framework is the de facto standard for Struts projects to validate input values both on the server side and the client side.

Is the same true for Spring MVC projects?

The reason I get the impression that it may not is that most Struts books and forums talk a lot about the Commons Validator framework, but only a few Spring books and forums do.

What's the best practice for validating input in Spring MVC projects?

Cheers!

+5  A: 

Commons Validator is more or less obsolete now, following the introduction of the JSR-303 Validation API, which Spring 3 fully supports. It's an annotation-driven declarative framework.

See the relevant parts (here and here) of the Spring docs to see how Spring uses it.

skaffman
It's also worth reading the documentation for an actual JSR-303 implementation after that. I'd suggest Hibernate Validator has the best docs: http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html/
GaryF
+1  A: 

I wrote examples on server-side validation using JSR-330 and rich client-side validation with Spring MVC as part of my Barebones Spring MVC series. These should give you some easy-to-follow examples to get you started.

James Earl Douglas