Struts 2 - Redirecting to a correct action after authentication interceptor

扶醉桌前 提交于 2019-11-28 00:30:32

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!