[英]how to fetch params defined in the action url in Interceptor
I have defined an action in struts.xml like this我在 struts.xml 中定义了一个动作,就像这样
<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我在操作 class "com.test.project1.abc" 中使用
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();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.