如何捕获FacesFileNotFoundException?

如何捕获FacesFileNotFoundException?,exception,jsf,jakarta-ee,try-catch,filenotfoundexception,Exception,Jsf,Jakarta Ee,Try Catch,Filenotfoundexception,我怎样才能赶上火车 com.sun.faces.context.FacesFileNotFoundException 在JavaEEWeb应用程序中 我尝试在web.xml文件中添加以下行,但没有成功: ... <error-page> <error-code>404</error-code> <location>/404.jsf</location> </error-page> <er

我怎样才能赶上火车

com.sun.faces.context.FacesFileNotFoundException

在JavaEEWeb应用程序中

我尝试在web.xml文件中添加以下行,但没有成功:

  ...
  <error-page>
    <error-code>404</error-code>
    <location>/404.jsf</location>
  </error-page>
  <error-page>
    <error-code>500</error-code>
    <location>/404.jsf</location>
  </error-page>
  <error-page>
    <exception-type>FacesFileNotFoundException</exception-type>
    <location>/404.jsf</location>
  </error-page>
  <error-page>
    <exception-type>FileNotFoundException</exception-type>
    <location>/404.jsf</location>
  </error-page>
  <error-page>
    <exception-type>FailingHttpStatusCodeException</exception-type>
    <location>/404.jsf</location>
  </error-page>
</web-app>
。。。
404
/404.jsf
500
/404.jsf
FacesFileNotFoundException
/404.jsf
FileNotFoundException
/404.jsf
失败TTPStatusCodeException
/404.jsf

您需要指定FQN(完整限定名),而不仅仅是N作为异常类型

<exception-type>com.sun.faces.context.FacesFileNotFoundException</exception-type>
com.sun.faces.context.FacesFileNotFoundException

或者,如果您已经使用了,请注册它,然后
FacesFileNotFoundException
将被处理为404。

到底发生了什么?输出如下:1。StandardWrapperValve[Faces Servlet]:PWC1406:Servlet Faces的Servlet.service()Servlet引发异常com.sun.Faces.context.FacesFileNotFoundException 2。PWC1231:Servlet的Servlet.service()面临Servlet引发异常3。org.apache.catalina.core。StandardHostValve@16933312:异常处理错误页面[exceptionType=com.sun.faces.context.FacesFileNotFoundException,location=/404.jsf]javax.servlet.ServletException:上下文已在javax.faces.webapp.FacesServlet.service(FacesServlet.java:422)中处于活动状态改为一个普通的JSP/HTML页面,然后重试!!!我想这是因为我想使用JSF来处理JSF异常,这是不可能的,因为JSF已经崩溃了(由于异常)!?非常感谢。