I have learned how to use Spring MVC 3, but I am very interested in background of it. One of the most interesting things to me is forms handling.
So far, I know that every http request in handled by dispatcher, mapped to proper controller. Controlles make some behind work, and than selects JSPX page to be loaded, and sends attributes to it. JSPX in compiled by container (Tomcat, etc…) to another servlet. Than web page is send back in http response.
This seems all right for me, in most case scenarios. But, form handling is different. In <form:form> tag, you defined object and attributes mapping to it. But in logic mentioned above, it actually never gets invoked. I mean, user requests page with form. So controller renders it. Than user send form, and some save method is invoked by dispatcher. But how does Spring know how to map incomming attributes, if they are described in JSPX that is not invoked?
Also, if you know any good, preferably web, resource on Spring MVC background, post a link. Thank you.
Well, the king of all Spring references is at
http://static.springsource.org/spring/docs/current/
There are long sections on the MVC, and on how to build pages using Spring tags.
The problem is, telling you to read that is like telling you to get a drink from a fire hose. As I have gotten better at using Spring, I’ve learned that knowing how to do one thing well in Spring means knowing how to do other things well with Spring.
It’s all worth learning, and the real strengths of Spring reveal themselves as you learn more about it.
Googling for “example spring form” turns up useful examples like the one at http://www.mkyong.com/spring-mvc/spring-mvc-form-handling-example/ But the problem with this approach toward learning is that Spring is constantly evolving. I’ve found that learning from random examples on the web is complicated by the fact that some people posted their examples before Spring 3 was available, or befor annotations were available, and so on.
For me, as I continue to learn Spring, there has not been one reference. It’s been the main reference, lots of examples on the web, and reading lots of questions here, and posting a few.