File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Does Struts 2 is using IOC Concepts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Does Struts 2 is using IOC Concepts?" Watch "Does Struts 2 is using IOC Concepts?" New topic

Does Struts 2 is using IOC Concepts?

Sonu Mishra

Joined: Jan 13, 2008
Posts: 1
Hi Friends,

I am using Struts 1.2. I want to know that Struts 2 is more like Spring. Does it Using IOC? How Struts 2 is more Customizable?

Thanks for your replies friends...
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 471

Hello Sonu,

Struts 2 is a web application framework (like struts). As far as I know, struts 2 doesn't have it's own IoC, but rather provide a plugin to use spring's IoC.

Visit my blog:
Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

Historically, WebWork uses its own DI container but recently it dropped it in favor of Spring as the default container.
And as Struts2 is based on WebWork2 code base, I think Spring is the DI container for Struts2 too.
Any way, waiting for experienced opinion...
Beppe Catanese

Joined: Nov 07, 2006
Posts: 28
It does, as previous reply confirms Struts2 is based on WebWork which has IoC. Specifically Struts2 supports interface injection where basically the Action (no longer implementing an interface but they are just standard POJOs) can be injected with the HttpSession, HttpServletRequest, etc..
The result is the decoupling of the Action classes with the Java Servlet API and much simple unit testing.
I agree. Here's the link:
subject: Does Struts 2 is using IOC Concepts?
It's not a secret anymore!