Announcement Announcement Module
Collapse
No announcement yet.
Validation annotations not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validation annotations not working

    Hi, I'm using Spring 3.0. I have a model with attributes like ...

    Code:
    public class RegistrationForm {
    
    	@NotBlank
    	private String firstName;
    	
    	@NotBlank
    	private String lastName;
    	...
    }
    and I also created a custom validator because I need to do some more advanced validation. I validate in my controller like so ...

    Code:
        @RequestMapping(method = RequestMethod.POST)
        public String onSubmit(HttpServletRequest request, HttpServletResponse response, Model model, @ModelAttribute("registrationForm") RegistrationForm form, BindingResult result) throws SQLException, IOException {
        	String viewName = "/account/register";
        	
        	// set custom Validation by user
            registrationValidation.validate(form, result);
    
        	 if (!result.hasErrors()) {
        	 ...
        	return viewName;
    }
    But even if I submit a blank form, nothing gets printed out in my "<form:errors />" tag. Is this because I have a custom validator ? Does anyone know how to get my annotations to be validated?

    Thanks, - Dave
Working...
X