Notes for injection in struts2 + spring

Source: Internet
Author: User

During struts2 + spring injection, a non-configuration file problem is found today. There are two methods.

1. Generally, it is better to create a baseaction.
For example

Public class baseaction extends actionsupport



Proteted usermanaer Mgr;

Public void setusermanager (usermanager MGR)


This. Mgr = Mgr;



Then those strutsactions can do this.
Public Class A extends baseaction





2. Implement the struts prepartion Interface

Public class personaction implements preparable {

Public personaction (personservice Service ){
This. Service = service;

The preparable interface instructs struts to call the "prepare" method, if "prepareinterceptor" is applied to the action (this is the default ). The action constructor has a "personservice" parameter. Spring is responsible for injection when the action is instantiated.


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: 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.