如果"beforePhase"发生异常,如何重定向到"ErrorPage" ?当我尝试重定向时,它给我一个"响应已提交"。
的问候Raj
检查下面的代码是否对您有帮助,
public void beforePhase(PhaseEvent e)
{
try
{
//if something doesn't work here
}
catch(Exception e)
{
System.out.println("Exception ocurred in beforePhase method");
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext externalContext = context.getExternalContext();
UIViewRoot newPage = context.getApplication().getViewHandler().createView(context,"/pages/techErrorPage.jsf");
context.setViewRoot(newPage);
context.renderResponse();
}
}