Book Image

Spring MVC Beginner's Guide

By : Amuthan Ganeshan
Book Image

Spring MVC Beginner's Guide

By: Amuthan Ganeshan

Overview of this book

Table of Contents (19 chapters)
Spring MVC Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Spring validation


We have seen how to incorporate the JSR-303 bean validation with Spring MVC. In addition to bean validation, Spring has its own classic mechanism to perform validation as well what is called Spring validation. The JSR-303 bean validation is much more elegant, expressive, and, in general, simpler to use compared to the classic Spring validation. However, the classic Spring validation is very flexible and extensible. For example, consider a cross-field validation where we want to compare two or more fields to see if their values can be considered as valid when combined. In such a case, we can use Spring validation.

In the last section, where we elaborated on the use of the JSR-303 bean validation, we validated some of the individual fields on our product domain object; we haven't done any validation that combines two or more fields. We don't know whether the combination of different fields makes sense.