【发布时间】:2015-10-12 20:16:49
【问题描述】:
我正在使用 JSF 2 OpenShift(显然是 JBoss 7 服务器)做一个项目,但我无法通过 Bean 重定向来解决问题。我正在用 Glassfish 在本地尝试一切。当我尝试访问“access.xhml”页面时出现我的问题,为了监控登录的用户,我输入了以下内容:
<f:metadata>
<f:event type="preRenderView" listener="#{sesion.checkSession()}" />
</f:metadata>
在方法的定义中我有以下内容
public void checkSession() throws IOException{
faceContext=FacesContext.getCurrentInstance();
httpServletRequest=(HttpServletRequest)faceContext.getExternalContext().getRequest();
if(httpServletRequest.getSession().getAttribute("connected")==null)
{
faceContext.getExternalContext().redirect(faceContext.getExternalContext().getRequestContextPath() + "/index.xhtml"); // For local changes
}
}
证明什么返回
faceContext.getExternalContext().getRequestContextPath()
我注意到它始终是 " " ,这向我表明重定向应该转到根目录。关键是当我尝试直接输入 www.my-app.rhcloud.com/access.xhtml 时总是抛出 500 错误
Exception when handling error trying to reset the response.: java.lang.IllegalStateException
at com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl...
at org.sindicatopygp.beans.SessionBean.checkSession(SessionBean.java:43)
有什么想法吗?我们感谢
【问题讨论】:
-
确切的完整消息标题是什么?只有
Exception when handling error trying to reset the response.: java.lang.IllegalStateException吗? -
完整的异常太大了,这个异常一定是问题所在(我猜)。其他的是级联异常。