You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by john lee <sh...@yahoo.com> on 2010/04/03 18:53:43 UTC

struts 2, how to trigger interceptor after action's execute() ?

 
***************************************************
<package name="me" extends="struts-default">
  <interceptors>
       <interceptor name="mysimple" class="mysimple">
          <param name="name"> try </param>
        </interceptor>
 </interceptors>
 
 <action name="try" class="try">
     <result name="success=">/success.jsp</result>
     <interceptor-ref name="mysimple">
            <param name="name"> try 2</param>
        </interceptor>
</action>
 
****************************************************
the above code triggers interceptor before class try's execute(), and the purpose of interceptor,
But, how to trigger interceptor again after class try's execute() ? i check the stuts 2 document, 
it just saying interceptor can trigger before and after execute, but never give the example for how to do it after execute(), 
 
anyone can help?
 
tks in advance
 
john


      

Re: struts 2, how to trigger interceptor after action's execute() ?

Posted by Robert Taylor <rt...@dtgresults.com>.
To trigger code before an Action is executed place it before the 
invocation.invoke().
To trigger code after an Action is executed place it after the 
invocation.invoke();

For example:

public String intercept(ActionInvocation invocation) throws Exception {
       MyAction action = (MyAction)invocation.getAction();
       // doBeforeActionExecuted();       String result = 
invocation.invoke();       // doAfterActionExecuted();       return result;
    }
hth,/robert----- Original Message ----- 
From: "john lee" <sh...@yahoo.com>
To: <us...@struts.apache.org>
Sent: Saturday, April 03, 2010 12:53 PM
Subject: struts 2, how to trigger interceptor after action's execute() ?



***************************************************
<package name="me" extends="struts-default">
<interceptors>
<interceptor name="mysimple" class="mysimple">
<param name="name"> try </param>
</interceptor>
</interceptors>

<action name="try" class="try">
<result name="success=">/success.jsp</result>
<interceptor-ref name="mysimple">
<param name="name"> try 2</param>
</interceptor>
</action>

****************************************************
the above code triggers interceptor before class try's execute(), and the 
purpose of interceptor,
But, how to trigger interceptor again after class try's execute() ? i check 
the stuts 2 document,
it just saying interceptor can trigger before and after execute, but never 
give the example for how to do it after execute(),

anyone can help?

tks in advance

john




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org