【问题标题】:How to redirect to "ErrorPage" if exception occurs in "beforePhase" method?如果“beforePhase”方法发生异常,如何重定向到“ErrorPage”?
【发布时间】:2012-12-13 16:54:04
【问题描述】:

如果“beforePhase”发生异常,如何重定向到“ErrorPage”?。当我尝试重定向时,它给了我一个“已经提交的响应”。

问候 拉杰

【问题讨论】:

  • 为什么不显示您尝试重定向的相关代码?

标签: jsf jsf-1.2 oracle-adf


【解决方案1】:

检查以下代码是否对您有帮助,

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();
  }
}

【讨论】:

    猜你喜欢
    • 2012-05-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-04
    • 2019-02-12
    • 2019-06-20
    • 2016-03-23
    • 1970-01-01
    • 2012-10-19
    相关资源
    最近更新 更多