Article: Get a better handle on Struts actions, with Spring
Submitted by Colin Sampaleanu on Thu, 2005-10-13 12:41
Get a better handle on Struts actions, with Spring, a DeveloperWorks article by George Franciscus, provides a detailed look at the 3 primary variations in how the Struts web UI framework may be integrated with Spring.
Copyright 2010,www.springsource.org - RSS - Managed Hosting by Contegix - Site maintained by SpringSource.
Upcoming Trainings:
Core Spring Framework
Feb 22 - 25: Wellington
Feb 23 - 26: London
Feb 23 - 26: Paris
Feb 23 - 26: Phoenix
Feb 23 - 26: Denver
Mar 02 - 05: Melbourne
Rich Web Applications with Spring
Feb 16 - 19: Online (US)
Mar 02 - 05: München
Mar 09 - 12: Chicago
Enterprise Integration with Spring
Feb 23 - 26: Minneapolis
Feb 23 - 26: Warsaw
Mar 09 - 12: Frankfurt
Plus:
Hibernate with Spring, Core Spring.NET, Spring Web Services and more...
User login
Upcoming events
- Spring 2GX Day - Madrid, Spain (Event)(10 days)
- SpringSource S2G Forum - Munich (Event)(37 days)













Good Article contains a possible Struts No No
I thought this artilcle was exceptionally good, but was concerned that the third recipe demonstrates DI in a struts action class by 'setting' the BookService member variable.
I've always understood that Struts action classes are similar to Servlets, so use of member variables (unless they are thread safe) is to be avoided.
Yes Yes
Since struts actions are cached, they must be thread-safe. That does't mean that you can't use instance variables. If those instance variables are thread safe, and the objects they reference are thread-safe, then everything is good. Servlets suffer the same problem because Servlets are pooled by the container. By default Spring delivers singletons. As long as the services are thread-safe (as all singletons should be), there is no danger.