<script language="javascript" type="text/javascript">
var timer;
//启动跳转的定时器
function startTimes() {
timer = window.setInterval(showSecondes,1000);
}
var i = 5;
function showSecondes() {
if (i > 0) {
i--;
document.getElementById("secondes").innerHTML = i;
}
else {
window.clearInterval(timer);
/*要跳转的请求*/
location.href = "toLogin.do";
}
}
//取消跳转
function resetTimer() {
if (timer != null && timer != undefined) {
window.clearInterval(timer);
/*取消跳转的请求*/
location.href = "toLogin.do";
}
}
</script>
<body class="error_page" onload="startTimes();">
<h1 id="error">
遇到错误, <span id="secondes">5</span> 秒后将自动跳转,立即跳转请点击
<a href="javascript:resetTimer();">返回</a>
</h1>
</body>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/WEB-INF/error.jsp</location><!--这里用绝对路径,因为不知道错误发生在哪里,无法写相对路径-->
</error-page>
<error-page>
<exception-type>400|405|500</exception-type><!--如果需要每个都要配置,所以推荐方案一 -->
<location>/WEB-INF/error.jsp</location>
</error-page>