How to redirect to the login page when the session expires?

后端 未结 2 1523
傲寒
傲寒 2021-02-11 10:09

I have three JSF 2.0 web modules and I need to redirect to the login page when the session expires.

I have tried it using a HttpSessionListener, it is call

2条回答
  •  迷失自我
    2021-02-11 10:47

    Try to use

     FacesContext.getCurrentInstance().getApplication().getNavigationHandler().
           handleNavigation(context, null, "LoginForm");
    

    But note that you should use Servlet Filter for these purposes, it's better to do not any redirection from PhaseListener because it's really error prone.

提交回复
热议问题