struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MK Tan" <>
Subject Re: [S2] Spring Injection
Date Wed, 23 May 2007 16:04:16 GMT
Let assume your base class is like this:
public class BaseAction extends ActionSupport {
    private MyService myService;
    public void setMyService(MyService service) {
        this.myService = service;

    //put others getter and setter here...

public class FooAction extends BaseAction {
//do whatever you want with myService

public class BarAction extends BaseAction {
//create anything you like with myService

in your applicationContext.xml, declare something shown below:
<bean id="baseAction" class="" abstract="true">
    <property name="myService" ref="myService"/>

<bean id="fooAction" class=""
<bean id="barAction" class=""

MK Tan
On 5/23/07, Roger Varley <> wrote:
> Hi
> I suspect that this going to be a stupid question but please bear with
> me. I have a BaseAction for my application that extends ActionSupport
> and all my actions extend BaseAction. BaseAction recieves a reference
> to a Service bean, through which my actions obtain objects from my
> Business Layer, by injection from the Spring container.
> Is there a way of configuring Struts and Spring so that I only need to
> do this for my BaseAction  and therefore avoid having to define all my
> actions to Spring or do I still need to inject the Service object into
> each action.
> I'm sorry if this is a really stupid question, but this is all new stuff
> to me.
> Regards
> Roger
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message