在服务器段运行此jsp网页可以显示服务器地址和刷新时间:
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%> // 防止生成乱码 <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Tomcat 1</title> </head> <body> <h2>这个网页运行于: Tomcat 1 </h2> <h3>
// 显示服务器地址: 内网地址: <% out.println(request.getLocalAddr() + " : " + request.getLocalPort()+"<br>");%> </h3> <div> <h3>刷新时间: <span id="time"> </span> </div> </body> <script src="js/jquery-3.2.1.min.js"></script> <script > var time; time = mytime(); $("#time").html(time); function mytime(){ var now=new Date();//创建对象 var year=now.getFullYear();//获取年份 var month=now.getMonth()+1;//获取月份 var date=now.getDate();//获取当天时间 var hours=now.getHours();//获取小时数 var minutes=now.getMinutes();//获取分钟 var seconds=now.getSeconds();//获取秒 var day=now.getDay();//获取星期几 if(now.getDay()==0)day="星期天"; if(now.getDay()==1)day="星期一"; if(now.getDay()==2)day="星期二"; if(now.getDay()==3)day="星期三"; if(now.getDay()==4)day="星期四"; if(now.getDay()==5)day="星期五"; if(now.getDay()==6)day="星期六"; var clock=year+"年"+month+"月"+date+"日 "+hours+":"+minutes+":"+seconds+" "+day;//相加 //document.write("当前的系统时间为:"+clock); return clock; // setTimeout(‘myrefresh()‘,1000); } </script> </html>