Time for action – combining Spring and bean validations

You need to write the previous bean validations again in a classic Spring-based validation, which is not a good idea, but thanks to the flexibility and extensibility of Spring validation, you can combine both a Spring-based validation and bean validation together with a little extra code. Perform the following steps:

  1. Create a class called ProductValidator under the com.packt.webstore.validator package in the source folder src/main/java. Then, add the following code into it:
    package com.packt.webstore.validator; import java.util.HashSet; import java.util.Set; import javax.validation.ConstraintViolation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.Errors; ...

Get Spring MVC Beginner’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.