【问题标题】:How to specify html page globally in Jboss?如何在 Jboss 中全局指定 html 页面?
【发布时间】:2013-02-02 12:38:13
【问题描述】:

如果用户未被授权,我们有一个过滤器将用户重定向到 error.html。现在,我们将 error.html 页面保存在 WAR 中,但是有没有办法让 html 文件公开,以便每个 war 文件都可以访问这个错误页面?如果我们将这个 html 页面作为 jar 并保存在 server/default/lib 中,那就更好了。

这是过滤器中使用的示例。

`reqDespacher = request.getRequestDispatcher("error.html")`

访问url是

http://localhost/Context_root/error.html

任何帮助将不胜感激。

【问题讨论】:

    标签: java jboss jboss7.x jboss5.x jboss6.x


    【解决方案1】:

    在 JBoss5 或 JBoss6 中,您可以复制并在您正在运行的服务器实例的 /deployer/jbossweb.deployer/web.xml 内定义此自定义 error.html。这将需要重新启动 JBoss 实例。错误代码 404 示例:

    <error-page>
                <error-code>404</error-code>
                <location><relative_path_to_error_html_file_under_jbossweb.deployer_folder></location>
    </error-page>
    

    其次,您应该使用&lt;error-page&gt;&lt;error-code&gt; 部署指令来定义自定义错误页面,而不是像当前那样通过手动指定页面来重定向请求。有关如何在 web.xml 上添加错误代码指令的详细示例,请参阅 specify-the-default-error-page-in-web-xml-in-servlet

    JBoss AS7 全局错误页面配置请看how-to-customize-jboss-as7-404-page

    【讨论】:

    • 这不是真正的全球性的吗?如果(在 AS 7 中)我想自定义显示在战争/应用程序上下文之外的 404 怎么办?
    猜你喜欢
    • 2011-05-24
    • 1970-01-01
    • 1970-01-01
    • 2015-11-09
    • 2010-12-08
    • 2012-08-14
    • 1970-01-01
    • 2016-07-08
    • 1970-01-01
    相关资源
    最近更新 更多