Spring and Struts Integration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.