日期:2014-05-16  浏览次数:20365 次

jsp自定义错误页

为了给浏览者一个友好的错误提示页面,我们可以自定义错误页面:
步骤如下:
一、打开WEB-INF 文件夹下web.xml 文件;
二、在里面新增:
<!-- 404
页面不存在错误 -->
<error-page>
?? <error-code>404</error-code>
?? <location>/errorpage404.htm</location>
</error-page>
<!-- 500
服务器内部错误 -->
<error-page>
?? <error-code>500</error-code>
?? <location>/errorpage500.htm</location>
</error-page>
<!-- java.lang.Exception
异常错误, 依据这个标记可定义多个类似错误提示 -->
<error-page>
?? <exception-type>java.lang.Exception</exception-type>
?? <location>/exception.htm</location>
</error-page>
三、保存web.xml 文件,重启应用服务器。