Can we integrate Struts 2.0 with Spring 3.0 +

3.5k Views Asked by At

I am new to Struts . Can we integrate Struts 2.0 with Spring 3.0 + . I am hearing people say "it is not possible to integrate it". Is this true .

If so is there any tutorial on the web having an example ?

edit :

There is a plugin to integrate Struts 2 and Spring 2 (struts2-spring-plugin-2.0.11.2.jar) . Do we have similar one for Struts 2 and Spring 3

2

There are 2 best solutions below

2
On BEST ANSWER

Well we always can use Spring 3.x with Struts 2.x and Struts2.x has already a plug in in place to accomplish this.

here is the link Struts2 spring Integration

Struts2 use its internal DI for creation of Actions,Results,Interceptor using the plug in will delegate the call of creation of these key objects to Spring DI. hope this will help you

edit

The Strus2 Spring Plug in works well even with Spring 3.x and we are using this in our current application it actually use your Spring jars and you have to place them in the lib.This plug in just overrides Struts2.x Object factory which is responsible for creating struts2 core component. So just go ahead do some experiment with it and if you face problem in integrating you can always post queries here

0
On

The Spring 3.0 documentation for Struts 1.x and 2.x is here.

It's technically possible to integrate Spring with really just about anything. For example you can use the IoC container from anywhere in your code by constructing a new ClassPathXmlApplicationContext and passing in a standard context XML resource on the classpath. There's generally not a need to do that though, as it integrates pretty well with most web frameworks. It is however convenient to use for unit tests.