如何在JSF 2.0中创建自定义404消息? [英] How to create custom 404 messages in JSF 2.0?
问题描述
目前在我的应用程序中,当用户在URL栏中键入一些非法目标时,看到以下内容:
我想让它更漂亮,并用我自己的标记和一点点
- 我是否需要在应用程序上编程,或者我必须在应用程序服务器中配置它?
- 我应该从哪里开始如果我想这样做? 您可以声明自定义< error-page>
s在 web.xml中取决于
< error-code>
( HTTP状态码)或< exception-type>
(已引发的完全限定的异常类名称,例如
/restored/3642969#3642969>javax.faces.application.ViewExpiredException
) lang-xml prettyprint-override>< error-page>
< error-code> 404< / error-code>
< location> /WEB-INF/errorpages/404.xhtml< / location>
< / error-page>
您可以自由填写 404.xhtml
。
Currently in my app when a user types some illegal destination in the URL bar, sees this:
I would like to make it more beautiful and customize it with my own markup and a bit of css.
-Do i need to program that on my app or i have to configure that in the application server?
-Where should i start from if i want to do that?
You can declare custom <error-page>
s in web.xml
depending on <error-code>
(the HTTP status code) or <exception-type>
(the full qualified exception class name which was been thrown, e.g. javax.faces.application.ViewExpiredException
).
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/errorpages/404.xhtml</location>
</error-page>
You've all freedom to fill in the markup in 404.xhtml
.
这篇关于如何在JSF 2.0中创建自定义404消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!