Mike London wrote:Good reply, a couple questions...
In your first Struts-like example below, would the model code (business logic) be in the handleRequestInternal() method before you return mav; ?
And, I'm assuming in the second example, based on your comment, the business logic would be where you wrote "do stuff here", right?
Thanks very much in advance.
- M
Correct on both counts - however, the preferred way of handling all this would be to write a service interface that handles the "business process" parts of your program, and invoke the service interface at these locations - not put this logic directly in the controller.
Usually Spring web apps use 3 layers -
1.) DAO (Data Access Object) layer - handles database interaction to store/load/find model objects.
2.) Service layer - handles business processes using model objects.
3.) Web layer - handles rendering web pages and translating request parameters into model object values.
You'd want to create a service layer interface/class to do what you need - something like below:
As for books - I used Pro Spring and Expert Spring MVC and WebFlow from Apress - both of these were for older versions of Spring, but I've heard there are new editions out. There's also a lot of tutorials and guides on springframework.com, and there are some examples packaged in the Spring distribution if you download the full version.