Changing request parameter value in Struts2 interceptor

后端 未结 2 1414
太阳男子
太阳男子 2021-01-25 13:20

Does anybody know if it is possible to change/remove request parameter values in a Struts2 interceptor?

The request parameter Map is an instance of Un

2条回答
  •  不要未来只要你来
    2021-01-25 14:22

    May be you can try as this.

    public String intercept(ActionInvocation invocation) throws Exception {
        final ActionContext context = invocation.getInvocationContext();
        Map parameters = (Map)context.get(ActionContext.PARAMETERS);
    
        Map parametersCopy = new HashMap();
        parametersCopy.putAll(parameters);
        parametersCopy.put("myParam", "changedValue");
    
        context.put(ActionContext.PARAMETERS, parametersCopy);
    
        return invocation.invoke();
    }
    

提交回复
热议问题