想了半天结果想出这么个办法:把下面的放到你的JSP中可以实现页面倒计时效果,直接将代码放到控制台的话加一个循环[code]<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
<%
response.setHeader("refresh" , "1" );
Calendar cal = Calendar.getInstance();
cal.set(2012, 8, 12, 0, 0, 0);
long longTime = cal.getTimeInMillis();
long currentTime = new Date().getTime();
long disTime = longTime - currentTime;
long day = ((disTime/1000)/(3600*24));
long hour = ((disTime/1000)-day*86400)/3600;
long minutes = (((disTime/1000)-day*86400) - hour*3600)/60;
long second = (disTime/1000) -day*86400 - hour*3600 - minutes*60;
out.println("伦敦奥运会倒计时" + day + "天 " + hour +"小时 " + minutes + "分 " + second + "秒 ");
%>
</body>
</html>[/code] |