Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

The example code for this tutorial, Spring_Struts2_Ant or Spring_Struts2_Mvnspring_struts, is available on Google Code - httpfor checkout at https://codesvn.google.com/p/struts2-examples/downloads/listImage Removed. After downloading and unzipping the file, you'll have a folder named Spring_Struts2_Ant (or Spring_Struts2_Mvn). In that folder will be a README.txt file with instructions on now to build and run the example application.apache.org/repos/asf/struts/sandbox/trunk/struts2examples/Image Added

Introduction

In the execute method of many Struts 2 ActionSupport classes are statements that create objects and then have those objects execute methods that perform needed tasks. Whenever one class creates an object of another class that introduces a dependency between the two classes. The Spring framework makes it easier for the application developer to manage these dependencies and helps make the application more flexible and maintainable. This tutorial will show you how to use Struts 2 and Spring together to manage the dependencies between your ActionSupport classes and other classes in your application.

...

For a Maven application you'll need to add a dependency to the struts2-spring-plugin jar (see the Maven example application for this tutorial). The plugin's pom.xml includes transitive dependencies to the Spring jar files. For an Ant built application you'll need to add the struts2-spring-plugin jar and the Spring jars to your application's class path (see the Ant example application for this tutorial).

Tip

The current version (2.3.1.215) of the Struts 2 Spring plugin has transitive dependencies to the Spring 3.0.5 version. If you want to use the latest version of Spring, then you should exclude the transitive dependencies in your pom.xml for the Struts 2 Spring plugin and then declare dependency nodes to the current version of the Spring jar files. If you are using Ant and explicitly including the jar files in your application, then just include the latest version of the Spring jar files.

...