an overview1. Purpose of Integration
with spring, all object creation tasks should be given to the spring container, not only to reduce the coupling of the code, but also to take advantage The spring container implements the proxy as a proxy factory.
2. Integration Goals
The bean in the spring container is injected into the action, give the action's creation and management to the spring container.
two implementations1. Basic
The integration of spring and struts is based on spring and web consolidation.
2. Integrated Rack Package
STRUTS2 provides a spring-compatible rack-mount Struts2-spring-plugin.jar that consolidates the need to import the rack package.
3.Spring Create action
After the spring-to-web integration is completed, the spring container injects the bean into the action by name, which completes the bean in the spring container
Tasks that are injected into the action, the tasks that the action creates and manages to give to the spring container are not completed, write the Spring configuration file:
<id= "Springactionname"class= "Xxxxaction"scope = "Prototype" > < name= "" ref= "">//Inject the bean referenced in the action </bean>
Action is a multi-instance, you must set the scope to prototype.
4.Struts References
< Packagename=""extends= "Struts-default"namespace=""><Actionname= "Myaction"class= "Springactionname">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</Action></ Package>
The action object created in the spring container is referenced by ID in Struts.xml.
Spring and Struts Integration