I have a User Modal
public class RegisterUser {
@Size(min = 2, max = 30)
private String fname;
@Size(min = 2, max = 30)
private String lname;
@NotEmpty
@Size(min = 6, max = 15)
private String password;
....
@NotEmpty
private String publicProfile;
... getters and setters
}
1) I want to use this modal during registration action (fname, lname, password etc but without publicProfile field)
2) I want to use this modal during myprofile action (all fields except password)
My action for register:
@RequestMapping(value = "/register", method = RequestMethod.POST)
public String submitRegisterForm(
@Valid RegisterUser registerUser,
BindingResult result,
Model m) {
....
}
Here I don't intend to provide 'publicprofile' on jsp and therefore do not want to validate this field although my Modal has @NotEmpty annotation
My action for myprofile
@RequestMapping(value = "/myprofile", method = RequestMethod.POST)
public String submitMyprofileForm(
@Valid RegisterUser registerUser,
BindingResult result,
Model m) {
....
}
Here I don't intend to provide 'password' field on jsp and therefore do not want to validate this field although my Modal has @NotEmpty and @Size(min = 6, max = 15) annotation
My question is how can I achieve this ?
Is there any way where I can say in this modal for this action validate only mentioned fields?
Thanks in advance
Manisha
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…