在我的项目中,当我的代码中出现特定错误时,我必须显示一个错误页面。
我在 header.xhtml 页面中添加了以下脚本。此页面添加到每个页面。因此,每当发生错误时,我都想显示错误页面。
<script type="text/javascript">
A4J.AJAX.onExpired = function(loc, expiredMsg) {
window.location = "../facelets/error/invalidSessionLogin.jsf";
};
A4J.AJAX.onError = function(req, status, message) {
window.location = "../facelets/error/ajaxError.jsf";
};
</script>
但这不起作用..
我还在web.xml中配置了500,404错误。代码如下。
<context-param>
<description>Use this to suppress Facelets error page</description>
<param-name>org.apache.myfaces.ERROR_HANDLING</param-name>
<param-value>false</param-value>
</context-param>
<error-page>
<error-code>500</error-code>
<location>/facelets/error/internalErrorHome.jsf</location>
</error-page>
<!-- if required page not available -->
<error-page>
<error-code>404</error-code>
<location>/facelets/error/pageNotFoundErrorHome.jsf</location>
</error-page>
但这给了我以下错误。
11:41:30,618 ERROR [[localhost]] Exception Processing ErrorPage[errorCode=404, location=/facelets/error/pageNotFoundErrorHome.jsf]
com.sun.faces.context.FacesFileNotFoundException: /facelets/error/pageNotFoundErrorHome.xhtml Not Found in ExternalContext as a Resource
我不知道我要去哪里错了..我不明白错误 Not Found in ExternalContext as a Resource