第二次JSP作业

1.p39 实验2 显示当前时间,并输出上午(0-12)好,下午好(13-17),晚上好(18-23)

<%@page import="java.time.LocalTime"%>
<%@page import="java.time.LocalDate"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
1.p39 实验2 显示当前时间,并输出上午(0-12)好,下午好(13-17),晚上好(18-23)
<%
LocalDate date = LocalDate.now();
LocalTime time = LocalTime.now();
%><br>
<%=date.getYear() %>
<%=date.getMonth() %>
<%=date.getDayOfMonth() %>
<%out.print("\n"); %><br>
小时为:<%int i =time.getHour();
out.print(i);%>
分钟为:<%=time.getMinute() %>
秒数为:<%=time.getSecond() %><br>
现在的问候:
<%if(i<=12){
	out.print("上午好");
}else if(i>12||i<=17){
	out.print("下午好");
}
else{
	out.print("晚上好");
}
%>>


</body>
</html>

  

2.使用声明方法,在页面调用该方法,判断2023是不是闰年

2023为:<%int year1 = 2023; %>
<%if(year1%4==0){
	out.print("闰年");
}else if(year1%4!=0){
	out.print("平年");
}%>



</body>
</html>

  

3.表达式+程序段 循环输出5条hr,长度分别为100px-500px

<%@page import="java.time.LocalTime"%>
<%@page import="java.time.LocalDate"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
3.表达式+程序段 循环输出5条hr,长度分别为100px-500px
<%
    for(int i=100;i<=500;i=i+100){    
     %>
     <hr width="<%=i%>" ><br>
     <%} %>
</body>
</html>

  

4.在第一题上加Java注释,第二题加html注释,第三题加jsp注释

 

posted @ 2022-03-14 15:51  李成前  阅读(25)  评论(0编辑  收藏  举报