在我的应用程序中,每当发生异常时,我都愿意导航到错误页面。被RuntimeException
处理和检查并再次抛出。为此,我在 Faces 配置中定义了一个全局导航规则:
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>error</from-outcome>
<to-view-id>/error.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
在我的catch
街区中,我试图导航为:
FacesContext fctx = FacesContext.getCurrentInstance();
Application application = fctx.getApplication();
NavigationHandler navHandler = application.getNavigationHandler();
navHandler.handleNavigation(fctx,null, "error");
但它不起作用。我Exception
强行抛出一个,但它没有导航到所需的错误页面。
任何指针都会对我很有帮助。