-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Spring MVC Cookbook
By :
After introducing the request-payload data binding process, we must talk about validation.
The goal of this recipe is to show how to get Spring MVC to reject request body payloads that are not satisfying a bean validation (JSR-303) or not satisfying the constraints of a defined Spring validator implementation.
After the Maven and Spring configuration, we will see how to bind a validator to an incoming request, how to define the validator to perform custom rules, how to set up a JSR-303 validation, and how to handle the validation results.
We added a Maven dependency to the hibernate validator:
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.3.1.Final</version> </dependency>
A LocalValidatorFactoryBean has been registered in our dispatcher-servlet.xml (cloudstreetmarket-api):
<bean id="validator" class="org.sfw...
Change the font size
Change margin width
Change background colour