如果用户未被授权,我们有一个过滤器将用户重定向到 error.html。现在,我们在 WAR 中保留了 error.html 页面,但是有没有办法公开 html 文件,以便每个 war 文件都可以访问这个错误页面?如果我们把这个 html 页面做成一个 jar 并保存在 server/default/lib 中,那就更好了。
这是过滤器中使用的示例。
`reqDespacher = request.getRequestDispatcher("error.html")`
and the accessing url is
http://localhost/Context_root/error.html
如有任何帮助,我们将不胜感激。
最佳答案
在JBoss5 或JBoss6 中,您可以复制然后定义此自定义error.html
在/deployer/jbossweb.deployer/web.xml
里面您正在运行的服务器实例。这将需要重新启动 JBoss 实例。错误代码 404 示例:
<error-page>
<error-code>404</error-code>
<location><relative_path_to_error_html_file_under_jbossweb.deployer_folder></location>
</error-page>
其次,您应该使用 <error-page>
,而不是像您当前那样通过手动指定页面来重定向请求。和 <error-code>
部署指令来定义自定义错误页面。参见 specify-the-default-error-page-in-web-xml-in-servlet有关如何在 web.xml 上添加错误代码指令的详细示例。
对于 JBoss AS7 全局错误页面配置,请查看 how-to-customize-jboss-as7-404-page .
关于java - 如何在Jboss中全局指定html页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14930252/