Interceptor can't access Action Parameters

后端 未结 1 551
轮回少年
轮回少年 2020-12-18 14:39

I\'m creating an example for struts2 interceptors. I created a simple login page and used a custom interceptor class to encrypt the input. But the interceptor is reading the

相关标签:
1条回答
  • 2020-12-18 15:23

    If you want to access parameters, the params interceptor should go first

    <action name="validatorAction" class="com.keyur.struts2.ActionClasses.validatorClass" method="execute">
       <interceptor-ref name="params"></interceptor-ref>
       <interceptor-ref name="encrypt"></interceptor-ref>
       <interceptor-ref name="defaultStack"></interceptor-ref>
       <result name="success">/success.jsp</result>
       <result name="input">/index.jsp</result>
    </action>
    

    Your problem is that those parameters don't go to the valueStack, and you should probably get them from the action context.

    Map params = ActionContext.getContext().getParameters();
    

    But after params interceptor they should be there.

    0 讨论(0)
提交回复
热议问题