0
在我的應用程序中,我願意在出現異常時導航到錯誤頁面。 RuntimeException
被處理並檢查並再次拋出。對於我在面配置定義的全局導航規則:以編程方式導航到JSF 2.0中的錯誤頁面
<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
,但它沒有導航到所需的錯誤頁面。
任何指針都會對我非常有幫助。
這不正是在JSF處理異常的正確方法。長話短說,檢查[此演示頁面](https://showcase-omnifaces.rhcloud.com/showcase/exceptionhandlers/FullAjaxExceptionHandler.xhtml)。 – BalusC