Hi all. I've spent a couple of weeks doing the various Spring MVC tutorials that are out there, and am now setting about coding an application. I have several years experience with Struts, and am basically recoding an existing Struts app with Spring, so as to learn its capabilities and differences.
I have a couple of initial questions which I hope you can help with.
1) When declaring a Controller in the myapp-servlet.xml file, I'm confused with the two properties 'successView' and 'formView'. They seem to be treated differently in all the examples I have seen. The success view always seems to have a file extension, ie 'success.htm' and refers to a mapping declared elsewhere in the file. But the form view, as far as I can tell, seems to refer directly to one of the files under the JSP directory. Why is this? Why are the two treated differently? Take this tutorial, I hope you'll see what I mean.
2) I want to know the best way of handling user-defined validation. For example, say I have a form with a field asking for a username. The standard Validation object will check that the field is not blank, and then if ok, forward onto the success view. Then, in the onSubmit() method of my controller, I want to interogate my database, and see if that user exists. If not, I want to return to the form, with an appropriate error message.
Now, in Struts, I would have found access to the ActionErrors object, and returned to the page, which worked fine. But here, I'm not sure if I have access to the Errors object - and even if I did, if I return to the original form in my return new ModelAndView code it seems to reset the form anyway.
How would you guys handle this kind of thing?
Many thanks for any help you can give!