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?
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();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.