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!

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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

These examples of server-side validation using JSR-330 rich client-side validation with Spring MVC should give you some easy-to-follow examples to get you started.

2 Comments

the two first links don't work anymore - would be cool if you could fix them.
The broken link has been fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.