【发布时间】:2017-10-26 14:52:29
【问题描述】:
我正在使用带有 JSF2 框架的 Glassfish 4 服务器。
我的问题
调用 response.sendRedirect 方法时,我遇到了 IllegalStateException。
我不知道为什么会引发此异常。
上下文
对于每个 xhtml 页面,我都会调用这个方法来检查用户是否仍然登录。
<body id="body" onload="#{utilisateurBean.isUserLoggedIn()}">
方法
public void isUserLoggedIn() throws IOException {
if(this.user == null){
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
response.sendRedirect("Project/accueil/index.xhtml");
}
}
例外
Infos: Exception when handling error trying to reset the response.
java.lang.IllegalStateException
或者
Avertissement: Servlet.service() for servlet session.AppExceptionHandler threw exception
java.lang.IllegalStateException: Cannot forward after response has been committed
我不知道为什么要提交响应。
感谢您的帮助:)
【问题讨论】: