Now, we will need to create the Application Context file for Spring. It will use the configuration information in this file to inject the necessary beans into each needed class. The file format is like below and it should be called WEB-INF/applicationContext.xml. I added some example beans to explain how Struts will later identify these beans and inject them into the Actions being called by the framework.

Last, but not least it is necessary to setup the struts.xml file to tell the framework that it should use struts' object factory. The example below will show the entries you need to add to struts.xml file. Setting "struts.objectFactory" to "spring" will force Struts to instantiate the actions using Spring, injecting all the defined dependencies on applicationContext.xml.

The "class" attribute for each action alias is set to "personAction", which is the bean id that we defined on applicationContext.xml for the PersonAction class. This is all that is needed to make Struts work with Spring.