开发者

How to define general/fall-back error page in web.xml

My Java web app currently maps certain error codes to an error servlet (spring web flow, actually, but that should be besides the point), by doing this in web.xml:

<error-page>
    开发者_运维问答<error-code>500</error-code>
    <location>/spring/error?error=500</location>
</error-page>
<error-page>
    <error-code>404</error-code>
    <location>/spring/error?error=404</location>
</error-page>

However, in certain cases the server will still crash and give a stack trace dump of some exceptions to the user. (Running on IBM WebSphere btw). My question then is; is it possible to define a fall-back error page that will be used if all other errors don't match? So that we're guaranteed not to end up with a stack trace under any circumstance.


Use the following:

<error-page> 
    <exception-type>java.lang.Throwable</exception-type> 
    <location>/error.jsp</location> 
</error-page>

See http://www.oracle.com/technology/sample_code/tech/java/codesnippet/servlets/HandlingServletExceptions/HandlingServletExceptions.html for more info.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜