问题描述
我已经在部署在 JBoss AS 7.1 中的 Web 应用程序中创建了一个自定义 404 页面.因此,如果我的应用程序位于 fubar dot com :8080/Myapp 并且我转到 fubar dot com :8080/Myapp/xyzzy,我将获得自定义错误页面(在 Web 应用程序的 web.
但是,当我访问 fubar dot com :8080/xyzzy 时,JBoss 会显示默认的 404 页面,该页面显示它是 JBoss 以及哪个 JBoss 版本.
我需要替换此页面以隐藏此信息.
请指教.
如果您想为 JBoss 7 中的所有其他上下文(您在 Myapp 应用程序中的配置的一部分)自定义错误页面,您还需要有:
- 禁用 JBoss 欢迎页面:在文件 standalone/configuration/standalone.
- 然后,您必须部署一个简单的 war 文件,将其上下文根设置为/",并为此战争定义错误页面(使用与 Myapp 相同的方法).因此,war 结构应该类似于(error.war 名称是任意的):
error.war||- 元信息|- 网络信息||||- web.
web.
<display-name>您的公司名称</display-name><错误页面><错误代码>404</错误代码><location>/error/404.html</location></错误页面></web-app>
在 jboss-web.
<context-root>/</context-root></jboss-web>
文件 404.html 是 Jboss 将显示的自定义 html 错误页面,而不是 404 默认错误.就是这样,在 JBoss 7 中部署这个应用程序,当您访问 fubar dot com:8080/yzyqqa 或任何其他根上下文时,您将拥有自定义的 404 错误页面.请记住,您还必须在 Myapp web.
顺便说一下,您是否考虑过让您的应用 Myapp 可以直接从 fubar dot com:8080 访问?或者甚至更好,让 jboss 服务器只能从代理(例如 Apache)访问?.这样你也可以避免这个问题.
希望能帮到你!
I already created a custom 404 page inside my web app deployed in JBoss AS 7.1.So if my app is at fubar dot com :8080/Myapp and I go to fubar dot com :8080/Myapp/xyzzy, I get the custom error page (defined in the web app's web.
However, when I go to fubar dot com :8080/xyzzy, JBoss displays the default 404 page which discloses that it's JBoss and which JBoss version.
I need to replace this page in order to hide this information.
Please advise.
If you want to customize the error pages for all the other contexts in JBoss 7, a part of the configuration you have in your Myapp application, you'll also have:
- to disable JBoss welcome page: in the file standalone/configuration/standalone.
- Then you'll have to deploy a simple war file setting its context-root to '/', and define the error page for this war (using the same method you've used for Myapp). So, the war structure should be similar to (the error.war name is arbitrary):
where The web.
<?
And in the jboss-web.
<jboss-web>
<context-root>/</context-root>
</jboss-web>
The file 404.html is your customized html error page that Jboss will show instead of the 404 default error. That's all, deploy this application in JBoss 7, and you'll have your custom 404 error page when you'll visit fubar dot com:8080/yzyqqa or whatever other root context. Remember that you'll have to keep the error configuration in your Myapp web.
By the way, have you considered making your app Myapp accessible directly from fubar dot com:8080? Or even better, making the jboss server only accessible from a proxy (for example Apache)?.This way you'd avoid this problem as well.
I hope it helps!
这篇关于如何自定义 JBoss AS7 404 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!