Versions Compared

Key

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

...

If you want to use the Spring as the object factory for your actions, then follow these steps:

  1. Place your Spring xml files under /META-INF/spring in the bundle jar file
  2. Copy all these jar files into /WEB-INF/classes/bundles in your application
  3. Make sure that the following properties are set(with the listed values) or not set at all in struts.xml or struts.properties in your webapp application:
    Code Block
    XML
    XML
    <constant name="struts.objectFactory" value="osgi" />
    <constant name="struts.objectFactory.delegate" value="spring" />
    <constant name="struts.freemarker.manager.classname" value="org.apache.struts2.osgi.BundleFreemarkerManager" />
    
  4. Place your Spring xml files under /META-INF/spring in the jar file
  5. Install the Struts 2 Spring plugin in your application
  6. Add
    Code Block
    XML
    XML
    
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
    to web.xml and an empty applicationContext.xml:
    Code Block
    XML
    XML
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC 
    	"-//SPRING//DTD BEAN//EN" 
    	"http://www.springframework.org/dtd/spring-beans.dtd">
    <beans></beans>
    
    under /WEB-INF/ in your application. This is a hack, but the Spring support doesn't work otherwise. TODO: find a way around this dirty hackInstall the Struts 2 Spring plugin in your application
  7. If you are going to use Velocity results, then add Velocity and Common Digester jars to your application. Using maven:
Code Block
XML
XML
<dependency>
    <groupId>velocity</groupId>
    <artifactId>velocity</artifactId>
    <version>1.5</version>
</dependency>

<dependency>
    <groupId>velocity-tools</groupId>
    <artifactId>velocity-tools</artifactId>
    <version>1.3</version>
</dependency>
        
<dependency>
    <groupId>commons-digester</groupId>
    <artifactId>commons-digester</artifactId>
    <version>1.8</version>
</dependency>

...