Struts 2 - Redirecting to a correct action after authentication interceptor

前端 未结 2 610
野性不改
野性不改 2020-12-06 14:57

I couldn\'t find anything online so I\'ll ask here. I\'m using strut2 and I have a private package of actions, cause certain actions require login to be access. So I have th

相关标签:
2条回答
  • 2020-12-06 15:34

    At the end I was able to make it work. Basically what I missed from the solution proposed by Roman C. was that I need to have a class variable saved (so not only have it in the session).

    private String savedUrl;

    public String getSavedUrl(){
        return savedUrl;
    }
    

    That did the trick.

    Thanks

    0 讨论(0)
  • 2020-12-06 15:39

    One of the possible solutions is to keep track of the user intercepting their URLs. You might do it in the authentication interceptor.

    String queryString = request.getQueryString();
    session.put("savedUrl", request.getRequestURI()+(queryString==null?"":("?"+queryString))); 
    

    use the global result with dynamic parameter

    @Results({
      @Result(name = "return", type = "redirect", location = "${savedUrl}")
    })
    

    after login check the session for savedUrl and return result "return". Assumed providing getter for the dynamic parameter.

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