设计一个jsp页面,要求在网页上显示当前日期和时间,如果时间在6:00~12:00,输出“上午好”:如果时间在12:00 18:00, 输出“下午好”:如果时间在18:0~24:00,输出“晚上好”:如果时间在0:00~6:CO,输出“凌晨好”
jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
Date d=new Date();
if(d.getHours()>=0&&d.getHours()<=6){
out.println(d+" 凌晨好");
}else if(d.getHours()>6&&d.getHours()<=12){
out.println(d+" 早上好");
}else if(d.getHours()>12&&d.getHours()<=18){
out.println(d+" 下午好");
}else{
out.println(d+" 晚上好");
}
%>
<br>
</body>
</html>
如有侵权联系我删除。