slz-关于记忆曲线的jsp-table
代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<table border="1px">
<tr>
<td>日期</td>
<td>新学期</td>
<td>复习前1课</td>
<td>复习前2课</td>
<td>复习前5课</td>
<td>复习前7课</td>
<td>复习前15课</td>
</tr>
<%
Date today=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
int group = 72;//代表有多少篇课文要背诵
int days =group+15;
for(int i=0;i<days;i++){
Calendar calendar=new GregorianCalendar();
//给日历一个初始时间
calendar.setTime(today);
calendar.add(java.util.Calendar.DATE, i);
//日历获取时间
String day=sdf.format(calendar.getTime());
String task1 = "";
String task2 = "";
String task3 = "";
String task4 = "";
String task5 = "";
String task6 = "";
//先求算任务1
if(i<=group-1){
task1 = (i+1)+"";
}else{
task1 = "—";
}
//先求算任务2
if(i<=0||i>=(group+1)){
task2 = "—";
}else{
task2 = i+"";
}
//先求算任务3
if(i<=0+1||i>=(group+2)){
task3 = "—";
}else{
task3 = (i-1)+"";
}
//先求算任务4
if(i<=0+3||i>=(group+4)){
task4 = "—";
}else{
task4 = (i-3)+"";
}
//先求算任务5
if(i<=0+6||i>=(group+7)){
task5 = "—";
}else{
task5 = (i-6)+"";
}
//先求算任务5
if(i<=0+14||i>=(group+15)){
task6 = "—";
}else{
task6 = (i-14)+"";
}
%>
<tr>
<td><%=day %></td>
<td><%=task1%></td>
<td><%=task2%></td>
<td><%=task3%></td>
<td><%=task4%></td>
<td><%=task5%></td>
<td><%=task6%></td>
</tr>
<%
}
%>
</table>
</body>
</html>
注意的地方:
这是jsp常用的page指令,注意import中,多个包和类用逗号隔开
JSP三大指令分别是:page指令、include指令和taglib指令
完成效果如下: