Struts2 redirecting to another action with unknown amount of parameters

后端 未结 1 383
情书的邮戳
情书的邮戳 2021-01-01 06:52

I have a login action which after succesful execution redirects to the previous page (I store the previous page in my session so I can fetch it later). In Struts2, I can fin

相关标签:
1条回答
  • 2021-01-01 07:38

    You can save action name, namespace, and parameters from the ActionMapping.

    ActionMapping mapping = ServletActionContext.getActionMapping();
    

    You can also save query string instead of parameter map.

    String params = request.getQueryString();
    

    To add parameters dynamically to redirectAction result you should use OGNL in a dynamic parameter.

    <param name="actionName">${previousAction.name +'?'+ parameters}</param>
    

    Supposed you have a getter for parameters and initialized it from session where you saved previous query string, action name, and namespace.

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