设计一个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>
如有侵权联系我删除。
本文介绍了一个使用JSP设计的网页,该网页能够显示当前的日期和时间,并根据时间的不同段落,输出相应的问候语,如“凌晨好”、“早上好”、“下午好”或“晚上好”。此设计利用了Java的日期处理功能。
6813

被折叠的 条评论
为什么被折叠?



