Blog的日历是怎么做的? 看过很多blog的日历,还可以检测某天是否有文章,一直很迷惑,不知道如何用Java 写一个Web日历与自己的数据库结合。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%@ page language="java" import="java.util.*" %> <%! String year; String month; %> <html> <head> <%@ page contentType="text/html;charset=GB2312" %><title>一个日历的例子 </title> </head> <%! String days[]; %> <% days=new String[42]; for(int i=0;i<42;i++) { days[i]=""; } %> <% Calendar thisMonth=Calendar.getInstance(); year=String.valueOf(thisMonth.get(Calendar.YEAR)); out.println(year); month=String.valueOf(thisMonth.get(Calendar.MONTH)); out.println(month); thisMonth.setFirstDayOfWeek(Calendar.SUNDAY); thisMonth.set(Calendar.DAY_OF_MONTH,1); int firstIndex=thisMonth.get(Calendar.DAY_OF_WEEK)-1; out.println(firstIndex); int maxIndex=thisMonth.getActualMaximum(Calendar.DAY_OF_MONTH); out.println(maxIndex); for(int i=0;i<maxIndex;i++) { days[firstIndex+i]=String.valueOf(i+1); } %> <body><center> <form name="sm" method="post" action="rili.jsp"> <h3> <%=year%>年 <%=Integer.parseInt(month)+1%>月 </h3> <table border="0" width="168" height="81"> <div align=center> <tr> <th width="25" height="16" bgcolor="#FFFF00"><font color="red">日</font> </th> <th width="25" height="16" bgcolor="#FFFF00">一</th> <th width="25" height="16" bgcolor="#FFFF00">二</th> <th width="25" height="16" bgcolor="#FFFF00">三</th> <th width="25" height="16" bgcolor="#FFFF00">四</th> <th width="25" height="16" bgcolor="#FFFF00">五</th> <th width="25" height="16" bgcolor="#FFFF00"> <font color="green">六</font></th> </tr> <% for(int j=0;j<6;j++) { %> <tr> <% for(int i=j*7;i<(j+1)*7;i++) { %> <td width="15%" height="16" bgcolor="#C0C0C0" valign="middle" align="center"> <%=days[i]%></td> <% } %> </tr> <% } %> </div> </table> </center> </body> </html> to chaucer518(喜欢凤晓的男生)你的例子不是动态得 想看例子又不怕麻烦的话,看看 Roller Weblogger 的代码,是个开源的 学习流程疑惑 mysql 优化批量插入 hibernate到MYSQL是乱码 很多方法都尝试啦 还是不行? 对于WEB权限设计问题探讨 送分!100分,求助海量数据的mysql索引问题! jsp多选项卡浏览问题 开源的世界如此美好 - Java Web开发技术随想 为什么通过form提交激活的jsp文件中无法访问session中的变量 求分页思路与技术 求问做个简单BBS用什么框架比较好 jsp里为什么request.getParameter取不到label的值? 紧急求救!
<%!
String year;
String month;
%>
<html>
<head>
<%@ page contentType="text/html;charset=GB2312" %>
<title>一个日历的例子 </title>
</head>
<%! String days[]; %>
<%
days=new String[42];
for(int i=0;i<42;i++)
{
days[i]="";
}
%>
<%
Calendar thisMonth=Calendar.getInstance();
year=String.valueOf(thisMonth.get(Calendar.YEAR));
out.println(year);
month=String.valueOf(thisMonth.get(Calendar.MONTH));
out.println(month);
thisMonth.setFirstDayOfWeek(Calendar.SUNDAY);
thisMonth.set(Calendar.DAY_OF_MONTH,1);
int firstIndex=thisMonth.get(Calendar.DAY_OF_WEEK)-1;
out.println(firstIndex);
int maxIndex=thisMonth.getActualMaximum(Calendar.DAY_OF_MONTH);
out.println(maxIndex);
for(int i=0;i<maxIndex;i++)
{
days[firstIndex+i]=String.valueOf(i+1);
}
%>
<body>
<center>
<form name="sm" method="post" action="rili.jsp">
<h3>
<%=year%>年
<%=Integer.parseInt(month)+1%>月
</h3>
<table border="0" width="168" height="81">
<div align=center>
<tr>
<th width="25" height="16" bgcolor="#FFFF00"><font color="red">日</font>
</th>
<th width="25" height="16" bgcolor="#FFFF00">一</th>
<th width="25" height="16" bgcolor="#FFFF00">二</th>
<th width="25" height="16" bgcolor="#FFFF00">三</th>
<th width="25" height="16" bgcolor="#FFFF00">四</th>
<th width="25" height="16" bgcolor="#FFFF00">五</th>
<th width="25" height="16" bgcolor="#FFFF00">
<font color="green">六</font>
</th>
</tr>
<% for(int j=0;j<6;j++) { %>
<tr>
<% for(int i=j*7;i<(j+1)*7;i++) { %>
<td width="15%" height="16" bgcolor="#C0C0C0" valign="middle" align="center">
<%=days[i]%>
</td>
<% } %>
</tr>
<% } %>
</div>
</table>
</center>
</body>
</html>