在 Servlet 3.0 或更高版本上,您可以指定
<web-app ...>
    <error-page>
        <location>/general-error.html</location>
    </error-page>
</web-app>
但是,由于您仍然使用Servlet 2.5,因此除了单独指定每个常见的HTTP错误之外,没有其他方法。您需要弄清楚最终用户可能面临的HTTP错误。在准系统Web应用程序上,例如使用HTTP身份验证,禁用目录列表,使用可能引发未处理的异常或未实现所有方法的自定义servlet和代码,然后您希望分别将其设置为HTTP错误401,403,500和503。
<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>
    <!-- Missing resource -->
    <error-code>404</error-code>
    <location>/Error404.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>
这应该包括最常见的问题。