JSF 1.2exception处理

我正在申请中处理exception处理。 我使用try catch块来捕获代码中出现的exception,我还可以通过编写监听器并在“faces-config.xml”中注册监听器来处理超时exception。

但是我遇到了在构造函数或错误代码500,400等中捕获意外错误(例如“NullPointerException”)的问题。

我使用了“web.xml”中的标签

 java.lang.Exception /sc00/ErrorPage.jsp  

我尝试了很多方法来处理exception,任何人都可以帮助我找到解决方案。 我尝试处理这些exception时得到的错误如下。

我使用的是JSF 1.2,服务器是websphere 8

控制台显示以下exception。

 com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause Faces Servlet: javax.servlet.ServletException E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: An exception was thrown by one of the service methods of the servlet [/sc00/ErrorPage.jsp] in application [MembershipEligibilityScreensEAR]. Exception created : [java.lang.RuntimeException: FacesContext not found 

我的错误页面位于/WebContent/sc00/ErrorPage.jsp中,ErrorPage.jsp没有与之关联的辅助bean。

许多解决方案让我看看Faces Servlet的URL路径,在我的web.xml中,servlet-mapping是如下

   Faces Servlet javax.faces.webapp.FacesServlet 1   Faces Servlet *.faces   Faces Servlet /faces/*  

我的faces-config.xml中的所有路径都引用/ FolderName / JspName,它们工作正常,即使在Navigation.xml中它们也能正常工作。

我如何将其导航到ErrorPage.jsp,有没有办法让我可以写一个监听器来解决这类问题

很抱歉发布了太多冗余的问题,我是JSF的新手,我不知道StackOverflow的规则,我为我造成的问题道歉。

任何解决方案将不胜感激。

  java.lang.RuntimeException: FacesContext not found 

当您通过URL请求包含JSF组件的JSP页面时,会发生这种情况,该URL与FacesServlet的URL模式(负责创建FacesContext )不匹配。

您需要更改错误页面位置以匹配在web.xml定义的FacesServlet的URL模式。 根据您对该主题的重复问题 ,这是*.faces ,因此如下设置错误页面位置应该如此,正如我在关于该主题的第一个问题的评论中所建议的那样。

 /sc00/ErrorPage.faces