I'm new to Spring MVC, hence the question may appear trivial.
I have a login form which is submitted via ajax and in return I receive a ModelAndView (displaying existing list of contacts of the user) from the Controller, which I use to overwrite the existing content - the existing login form HTML upon success. My model object contains the list of validation errors which gets populated if there were errors in my form.
I want to show validation errors in my login form if there are any. How should I go about implementing it - should I send a JSON instead of HTML from the server and construct the page at the client using jQuery templates - or can this be achieved even if the Controller returns a ModelAndView?
I have considered having the login JSP and the contacts JSP combined into one and hide/unhide based on response. I do not want to do this though, as this would only increase the payload to be sent to the client.
I think this is a very common problem so there should already be best practices/design approaches for handling this.