Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does Struts 2 is using IOC Concepts?

 
Sonu Mishra
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 471
Hibernate Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic