Spring Framework

Spring Projects

Spring Project 1

Validate Interface in Spring MVC
Previous Home Next

The Validate Interface in Spring MVC provide the facility to give the service before execute of your action class and give the service after execute of your action class. This interface provide the following type of method which are:


boolean supports(Class clazz)

Can this Validator validate instances of the supplied clazz?


void validate(Object target,Errors errors)


package mypack.validator;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import mypack.model.Registration;
import mypack.model.Registration;
public class RegistrationFormValidator 
implements Validator 
public boolean supports(Class clazz) {
return Registration.class.isAssignableFrom(clazz);
public void validate(Object obj, Errors errors) {
Registration registration = (Registration) obj;
"username", "error.blank.username");
"password", "error.blank.password");

Example of Validator Interface in Spring MVC

Previous Home Next