[英]how to fetch params defined in the action url in Interceptor
我在 struts.xml 中定義了一個動作,就像這樣
<action name="*/*/execute" class="com.test.project1.abc" method="execute">
<param name="username">{1}</param>
<param name="resource">{2}</param>
如何在攔截器中獲取用戶名和資源的值?
我在操作 class "com.test.project1.abc" 中使用
ActionContext context = ActionContext.getContext();
Map<String, Object> params = context.getParameters();
但是,上述內容不會在攔截器中產生結果。 那么在這種情況下我應該如何獲取參數呢?
你可以嘗試這樣的事情:
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.