【发布时间】:2025-12-18 21:20:01
【问题描述】:
我必须在会话超时后注销用户。我使用EventListenter 清除会话,还使用PhaseListener 在执行任何处理之前验证用户。
当我在会话超时后尝试单击任何按钮时出现以下异常:
java.lang.IllegalStateException
org.apache.catalina.connector.ResponseFacade.reset(ResponseFacade.java:310)
com.sun.faces.context.ExternalContextImpl.responseReset(ExternalContextImpl.java:821)
com.sun.faces.context.ExceptionHandlerImpl.throwIt(ExceptionHandlerImpl.java:251)
com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:141)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:113)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:395)
我的 web.xml 有以下条目:
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/content/country/default/jsp/login.faces</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/content/country/default/jsp/error.faces</location>
</error-page>
PhaseListener 中的一段代码是
try{
log.info("------------Check the method call-----------");
if (log.isDebugEnabled())
log.info("Authentication is needed. Navigating to login page.");
nh.handleNavigation(fc, null, NavigationConstants.LOGIN_FAILURE.toString());
return;
}catch(ViewExpiredException ve){
log.info("Got the view expired exception. . . ");
FacesContext.getCurrentInstance().getExternalContext().redirect("login.faces");
}catch(IllegalStateException e){
log.info("Got the IllegalStateException . . ");
FacesContext.getCurrentInstance().getExternalContext().redirect("login.faces");
}catch(Exception ex){
log.info("Got the Exception . . ",ex);
FacesContext.getCurrentInstance().getExternalContext().redirect("login.faces");
【问题讨论】:
标签: jsf