jboss,tomcat通配符错误页面配置

02-08 20:59:02   来源:admin   评论: 点击:

如何在web xml中指定默认的错误页面?在 Servlet 3 0或者更高版,你可以通过下面的方式指定:<error-page> <location> general-error ht
 如何在web.xml中指定默认的错误页面?

在 Servlet 3.0或者更高版,你可以通过下面的方式指定:
<error-page>
    <location>/general-error.html</location>
</error-page>

But as you're still on Servlet 2.5, there's no other way than specifying every common HTTP error individually. You need to figure which HTTP errors the enduser could possibly face. On a barebones webapp with for example the usage of HTTP authentication, having a disabled directory listing, using custom servlets and code which can possibly throw unhandled exceptions or does not have all methods implemented, then you'd like to set it for HTTP errors 401, 403, 500 and 503 respectively.

<error-page>
    <!-- Missing login -->
    <error-code>401</error-code>
    <location>/general-error.html</location>
</error-page>
<error-page>
    <!-- Forbidden directory listing -->
    <error-code>403</error-code>
    <location>/general-error.html</location>
</error-page>
<error-page>
    <!-- Uncaught exception -->
    <error-code>500</error-code>
    <location>/general-error.html</location>
</error-page>
<error-page>
    <!-- Unsupported servlet method -->
    <error-code>503</error-code>
    <location>/general-error.html</location>
</error-page>
That should cover the most common ones.

相关热词搜索:jboss tomcat servlet

上一篇:JBOSS5.1安全策略:隐藏header信息,以及40x,50x错误页面有关jboss 下一篇:最后一页
分享到: 收藏