在安装httpserver2.2.x正常使用的基础上:
1、虚拟机配置:
<VirtualHost *:80>
ServerAdmin admin@machengshuang.cn
ServerName www.machengshuang.cn
ServerAlias www.machengshuang.cn
DocumentRoot "D:\Httpserver-2.2.25\htdocs\antma"
</VirtualHost>
2、在htdocs\antma 目录下建两个文件 index.html error.html
index.html 如下(引用了jquery):
<!DOCTYPE html>
<head>
<title>加载中...</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type : "get",
url : "http://localhost:8080/project/", //Tomcat项目地址
data : null,
cache : false,
beforeSend : function(){
},
success : function(resp) {
window.location.href = 'http://localhost:8080/project'; //Tomcat项目地址
},
error : function() {
window.location.href = './error.html';
},
complete : function(){
}
});
});
</script>
</head>
<body>
</body>
</html>
error.html 如下:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>系统正在维护</title> <style> * {margin:0;padding:0;} body {background:url(images/bg.png) no-repeat;background-position:top center;width:100%;height:100%;position:relative;} .time {font-size:30px;color:#000000;position:fixed;left:50%;margin-left:-160px;margin-top:380px;} </style> <script src="jquery-1.10.2.js"></script> <script type="text/javascript"> function getIndex(){ $.ajax({ type : "get",
data : null,cache : false,beforeSend : function(){},success : function(resp) {clearInterval(timer);url : "http://localhost:8080/project/", //Tomcat项目地址
},error : function() {},complete : function(){}});}var timer=setInterval(getIndex,60000); </script></head><body> <span class="time"> 预计恢复时间:20:30 </span></body></html> 进入error.html 后,会定时访问Tomcat 项目地址可用性,一旦可用,自动跳转到项目页面window.location.href = 'http://localhost:8080/project'; //Tomcat项目地址