【发布时间】:2015-08-20 08:14:12
【问题描述】:
我的 JSF 2.2 webapp 在 web.xml 中有一个自定义异常映射,如下所示。
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Project</display-name>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<session-config>
<!-- some codes-->
</session-config>
<error-page>
<exception-type>se.telenor.ocfd.service.api.exception.CustomNotFoundException</exception-type>
<location>/not_found.xhtml</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/404.xhtml</location>
</error-page>
<error-page>
<location>/500.xhtml</location>
</error-page>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/session_timeout.xhtml</location>
</error-page>
</web-app>
我的例外是
@ApplicationException
public class CustomNotFoundException extends RuntimeException {
private static final long serialVersionUID = 1L;
public CustomNotFoundException(String message, Throwable cause) {
super(message, cause);
}
public CustomNotFoundException(String message) {
super(message);
}
}
但是当异常发生时它确实是not redirect me to not_found.xhtml页面而不是always redirect to 500.xhtml页面。
如果缺少任何东西,有人可以帮助我吗?
【问题讨论】:
标签: jsf exception-handling custom-error-pages