0

I have defined an action in struts.xml like this

<action name="*/*/execute" class="com.test.project1.abc" method="execute">
        <param name="username">{1}</param>
        <param name="resource">{2}</param>

How can i fetch the values of username and resource in interceptor ?

I have fetched these values in the action class "com.test.project1.abc" using

ActionContext context = ActionContext.getContext();
Map<String, Object> params = context.getParameters();

However the above does not yield results in an interceptor. So how should i fetch the params in this case ?

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Sivakami Subbu
  • 344
  • 3
  • 11

1 Answers1

0

You can try something like this:

public String intercept(ActionInvocation invocation) throws Exception {
    final ActionContext context = invocation.getInvocationContext();
    Map<String,Object> reqParams = (Map<String,Object>)context.get(ActionContext.PARAMETERS);

    /**
    * Your logic
    */

    return invocation.invoke();
}

Nish
  • 922
  • 13
  • 31