I'm trying to implement spring validation framework in my mvc application. My login page has user name and password which are mandatory. I defined them as not null and not empty in the model class. If they are left blank I expect spring to bind the errors to BindingResult object. I'm not sure where I'm doing it wrong.. the hasError() method of BindingResult always return false in my controller class.
I took your code and built this app. I can't believe you actually got it to the validation stage, because I had to fix some pieces prior to getting it to run.
First, needed to be changed to , because doesn't exist in your controller.
Second, the tag doesn't appear to support 'required' or 'autofocus', so I got rid of them.
I commented-out the call to authenticationService to simplify testing.
Once I made the above changes, the @Validation worked properly for hibernate validating username and password fields.
I just copied your controller code, built and restarted the app. It is directly going to welcome page even if I leave username blank. There is certainly something else is going on. Not sure, what it is.. but for now, I have to go with implementing validator interface. Please let me know, if anything else strikes your mind. Thank you for all your time.