看过很多blog的日历,还可以检测某天是否有文章,一直很迷惑,不知道如何用Java 写一个Web日历与自己的数据库结合。

解决方案 »

  1.   

    <%@ 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>
      

  2.   

    to  chaucer518(喜欢凤晓的男生)你的例子不是动态得
      

  3.   

    想看例子又不怕麻烦的话,看看 Roller Weblogger 的代码,是个开源的