struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Cook" <>
Subject RE: Some Spring/Struts questions
Date Wed, 12 May 2010 13:39:50 GMT
That would be my favoured route.

Wes, side question. Using the convention plugin can you modify the stack
in the xml file so you don't have to annotate the action itself? Or do
you still have to add the annotation with the interceptor put in?


-----Original Message-----
From: Wes Wannemacher [] 
Sent: 12 May 2010 14:33
To: Struts Users Mailing List
Subject: Re: Some Spring/Struts questions

I've seen a few responses, but I think the best way would be to write
an interceptor that places the bean into the session. Give it a known
name in the session, then you can use OGNL to access it... Here is a
quick example of the interceptor -

public class CustomInterceptor extends AbstractInterceptor {

    private SomeBeanGeneratingService someBeanGeneratingService;

    public String intercept(ActionInvocation invocation) throws
Exception {
       return invocation.invoke();

    public void setSomeBeanGeneratingService(SomeBeanGeneratingService
someBeanGeneratingService) {
        this.someBeanGeneratingService = someBeanGeneratingService;

The benefit is using an interceptor is two-fold... One is that it's
pretty easy to unit test (compared to a Servlet Filter). Two is that
it can be spring-configured and spring-injected.

With this interceptor putting the bean into the session, you can
access the bean's values through OGNL. Here is an example s:property
tag retrieving some property -

<s:property value="%{#session.knownBeanName.someProperty}" />

Then, configure the interceptor and dependencies and put this
interceptor in your stack.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message