调试错误跳转页面出现一个问题,即在web.xml中配置的<error-page></error-page>不起作用,在web.xml中配置代码通常有两种方式:
1、根据错误代码
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
2、根据异常类型
<error-page exception-type="java.lang.NullPointerException" location="/nullpointer.jsp"/>
注1:对于resin服务器也可以将错误跳转配置在resin-web.xml文件中,效果一样。
对于无法跳转的解决:
1.确保location属性中填写的错误页面是绝对路径
2.确保error.jsp的大小>1024字节
3.确保在error.jsp页面中添加<%@ page isErrorPage="true"%>
注2:对于服务器端程序我们无法要求客户端去修改IE配置,因此流行的“在IE【工具】->【Internet选项】->【高级】中勾掉【显示友好http错误提示】”这种解决办法一般不予考虑;不管在哪个配置文件中配置,如果不起作用,通常是由于错误文件太小引起的,error.jsp的大小要大于1024字节。