重定向到JSF中的错误页面 [英] Redirect to an error page in JSF

查看:140
本文介绍了重定向到JSF中的错误页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JSF 2richFaces 4在Web应用程序中工作,我想处理带有错误页面的异常.我使用了JSF标准.一切正常,但是当引发异常时,我会显示带有异常详细信息的错误页面,但是我们并没有真正重定向到错误页面,因为在地址栏中,我拥有引发异常的页面的URL.由于这个问题,我在错误页面中的链接和图像路径还有其他问题.

Im working in a web application using JSF 2 and richFaces 4 and I want to handle exceptions with an error page. I used the JSF standard. Every thing works good but when an exception is throwed I have the error page with the exception details but we are not really redirected to the error page because in the address bar I have the URL of the page where the exception was thrown. Due to this problem I have other problems with links and images paths in the error page.

谢谢.

推荐答案

使用标准API工具是不可能的.如果您重定向,则有关该异常的信息将丢失.

That's not possible using the standard API facilities. If you redirect, then the information about the exception would get lost.

关于您的具体问题,

由于这个问题,我在错误页面中的链接和图像路径还有其他问题.

应该永远不会构成问题的

.这只是开发人员自己的错误.显然,您是在使它们相对于请求URL进行访问,这的确在引起麻烦.您应该使它们相对于域根目录.

that should never have formed a problem. This is just developer's own mistake. Apparently you're making them relative to the request URL, which is indeed asking for trouble. You should make them relative to the domain root instead.

例如

<a href="#{request.contextPath}/index.xhtml">Index</a>
<img src="#{request.contextPath}/resources/images/logo.png" />

但是更好的是使用真正的JSF组件而不是普通的HTML.它们将自动在上下文路径之前添加.

But much better is to use real JSF components instead of plain vanilla HTML. They will automatically prepend the context path.

<h:link value="Index" outcome="/index.xhtml" />
<h:graphicImage name="images/logo.png" />

这篇关于重定向到JSF中的错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆