我有 ErrorPage.jsp 我有
<h:messages styleClass="messageError" id="messages1"></h:messages>
当支持 bean 构造函数中发生异常时,我捕获它并执行以下操作
public constructorxxx throws Exception{
// code
// code
// code
catch(Exception e){
try{
LOG.error(e);
String customMessage = "An Unknown Error At " + e.getStackTrace()[0].toString() + "at" + message;
getFacesContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
customMessage, null));
throw new Exception();
}catch (IOException exception){
LOG.error(exception);
}
}
} // end of constructor
在我的 Web.xml 中,我使用了以下标签。
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/ErrorPage.jsp</location>
当我这样做时,我收到以下错误
1) Uncaught service() exception root cause Faces Servlet: javax.servlet.ServletException
2) 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.
and in my page it displays as
SRVE0260E: The server cannot use the error page specified for your application to handle the Original Exception printed below.
Error Message: javax.servlet.ServletException
Error Code: 500
Target Servlet: Faces Servlet
Error Stack:
java.lang.Exception
// stack trace
Error Message: java.lang.RuntimeException: FacesContext not found
Error Code: 0
Target Servlet:
Error Stack:
java.lang.RuntimeException: FacesContext not found
很多人要求我将 ErrorPage.jsp 的位置更改为 /sc00/ErrorPage.faces 但它在我的 web.xml 上显示链接断开警告,错误是网页无法显示和编程错误。
我正在使用 jsf 1.2,而我的“ErrorPage.jsp”没有支持 bean。
谁能建议我为什么没有显示 Error.jsp ?