如果异常不同,我想在显示特定用户异常时显示自定义错误页面(CustomException)并显示标准Tomcat错误页面(打印了stacktrace的HTTP状态500)。
所以我在我的web.xml中添加了:
<error-page>
<error-code>404</error-code>
<location>/xhtml/commun/error.xhtml</location>
</error-page>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/xhtml/commun/expired.xhtml</location>
</error-page>
<error-page>
<exception-type>organization.CustomException</exception-type>
<location>/xhtml/commun/error.xhtml</location>
</error-page>
但是,遇到CustomException以外的异常时,导航器上的内容会冻结(客户端没有任何反应),并且我在服务器端有这个日志:
nov. 09, 2015 4:12:56 PM org.apache.catalina.core.StandardWrapperValve invoke GRAVE: "Servlet.service()" pour la servlet Faces Servlet a généré une exception java.lang.IllegalArgumentException: Either HTTP 500 or java.lang.Throwable error page is required in web.xml or web-fragment.xml. Neither was found.
at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handleAjaxException(FullAjaxExceptionHandler.java:207)
at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handle(FullAjaxExceptionHandler.java:176)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:198)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:176)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
是否可以显示特定异常类型或错误代码的默认Tomcat错误页面?