java - Spring MVC - validation for comparing two fields -


i'm working on spring mvc application , have question spring validation. first, have action in controller:

@requestmapping(value = "/create", method = requestmethod.post, produces = "application/json") public @responsebody employee employeecreate(@valid @requestbody employeemodelcreate objmodel) throws exception {   ... } 

and employeemodelcreate class:

public class employeemodelcreate implements serializable {     ...     @notblank(message = "...")     private string password;      @notblank(message = "...")     private string confirmpassword;     ...      //setters , getters } 

now, want have validation comparing password , confirmpassword. validation should check equality of these 2 fields. how can that? appreciated.

you make custom validation class, need implement validator interface, can use manually, or bind spring mvc controller, using @initbinder annotation.

this question may contain other useful information.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -