有谁知道如何用JSP做出象CSDN首页日历那样的程序。急!!!!!

lingzi 2002-05-30 07:08:08
有谁知道如何用JSP做出象CSDN首页日历那样的程序.当点红色的日期时候弹出响应的页或提示。能给出详细代码吗?
...全文
46 点赞 收藏 11
写回复
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
lingzi 2002-05-30
to :ylunar(越) 不行啊提示错误:Error: Type GregorianCalendar was not found.
回复
lingzi 2002-05-30
to :ylunar(越) 不行啊提示错误:Error: Type GregorianCalendar was not found.
回复
zijianyi 2002-05-30
如果我没有猜错的话,那个是用asp.net直接拖的控件.......
回复
ylunar 2002-05-30
对了,还要在显示的时候加上相应的连接。
回复
ylunar 2002-05-30
以下代码也许合用:
<%@page contentType="text/html;charset=GB2312"%>
<%@page
import="java.util.Date"
import="java.util.GregorianCalendar"
import="java.util.Calendar"
%>
<%
/*
************************************************************
TodayMonth 当天的月份
TodayYear 当天的年份
TodayMaxDay 当天的月份有多少天
TodayOfWeek 当天是星期几
TodayNum 当天是本月中的多少号
TodayWeekNum 当天在在本月中属于第几个星期
TodayFirstOfWeek 当天月份的第一天是星期几
TodayLastOfWeek 当天月份的最后一天是星期几

SelDayMonth 选定某天的月份
SelDayYear 选定某天的年份
SelDayMaxDay 选定某天的月份有多少天
SelDayOfWeek 选定某天是星期几
SelDayNum 选定某天是本月中的多少号
SelDayWeekNum 选定某天在在本月中属于第几个星期
SelFirstOfWeek 选定某天月份的第一天的星期数
SelLastOfweek 选定某天月份最后一天的星期数

Flag 标记是否选择了月份
***********************************************************
*/

String Flag="";

int get_year=0; //获取用户选择的年月日
int get_month=0;
int get_day=0;

int TodayYear=0;
int TodayMonth=0;
int TodayMaxDay=0;
int TodayOfWeek=0;
int TodayNum=0;
int TodayWeekNum=0;

int TodayFirstOfWeek=0;
int TodayLastOfWeek=0;

GregorianCalendar TodayCal=null;
GregorianCalendar TodayFirstCal=null;
GregorianCalendar TodayLastCal=null;

if(request.getParameter("theflag")==null)
Flag="one"; //第一次加载时
else
Flag="two"; //用户翻动时

if(Flag.equals("one"))
{
TodayCal=new GregorianCalendar();
TodayYear=TodayCal.get(TodayCal.YEAR);
TodayMonth=TodayCal.get(TodayCal.MONTH);
TodayMaxDay=TodayCal.getActualMaximum(Calendar.DAY_OF_MONTH); //本月有多少天
TodayOfWeek=TodayCal.get(TodayCal.DAY_OF_WEEK); //星期几
TodayNum=TodayCal.get(TodayCal.DAY_OF_MONTH);
TodayWeekNum=TodayCal.get(TodayCal.WEEK_OF_MONTH);

TodayFirstCal=new GregorianCalendar(TodayYear,TodayMonth,1);
TodayFirstOfWeek=TodayFirstCal.get(TodayFirstCal.DAY_OF_WEEK);

TodayLastCal=new GregorianCalendar(TodayYear,TodayMonth,TodayMaxDay);
TodayLastOfWeek=TodayLastCal.get(TodayLastCal.DAY_OF_WEEK);
}
else
{
get_year=Integer.parseInt((String)request.getParameter("theyear"));
get_month=Integer.parseInt((String)request.getParameter("themonth"));
get_day=Integer.parseInt((String)request.getParameter("theday"));

TodayCal=new GregorianCalendar(get_year,get_month,get_day);
TodayYear=TodayCal.get(TodayCal.YEAR);
TodayMonth=TodayCal.get(TodayCal.MONTH);
TodayMaxDay=TodayCal.getActualMaximum(Calendar.DAY_OF_MONTH); //本月有多少天
TodayOfWeek=TodayCal.get(TodayCal.DAY_OF_WEEK); //星期几
TodayNum=TodayCal.get(TodayCal.DAY_OF_MONTH);
TodayWeekNum=TodayCal.get(TodayCal.WEEK_OF_MONTH);

TodayFirstCal=new GregorianCalendar(TodayYear,TodayMonth,1);
TodayFirstOfWeek=TodayFirstCal.get(TodayFirstCal.DAY_OF_WEEK);

TodayLastCal=new GregorianCalendar(TodayYear,TodayMonth,TodayMaxDay);
TodayLastOfWeek=TodayLastCal.get(TodayLastCal.DAY_OF_WEEK);
}
%>
<html>
<body>
<table width="20%" border="0">
<tr>
<td ><b><%=TodayYear%>年<%=TodayMonth+1%>月</b></td>
<td><font color=red><a href=<%out.println("Calendar.jsp?theyear="+TodayYear+"&themonth="+(TodayMonth-1)+"&theday=1&theflag=b");%>>前</a></td>
<td><font color=red><a href=<%out.println("Calendar.jsp?theyear="+TodayYear+"&themonth="+(TodayMonth+1)+"&theday=1&theflag=b");%>>后</a></td>
</tr>
</table>
<table width="20%" border="0">
<tr>
<td><font color=green>日</font></td>
<td>一</td>
<td>二</td>
<td>三</td>
<td>四</td>
<td>五</td>
<td><font color=green>六</font></td>
</tr>
<tr>
<%
//定义5行7列的表格,i是行数,j是列数
int z=0;
switch(TodayFirstOfWeek)
{
case 1: //星期天
%>
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td>
<%
z=7;
break;
case 2: //星期一
%>
<td> </td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td>
<%
z=6;
break;
case 3: //星期二
%>
<td> </td><td> </td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td>
<%
z=5;
break;
case 4: //星期三
%>
<td> </td><td> </td><td> </td><td>1</td><td>2</td><td>3</td><td>4</td>
<%
z=4;
break;
case 5: //星期四
%>
<td> </td><td> </td><td> </td><td> </td><td>1</td><td>2</td><td>3</td>
<%
z=3;
break;
case 6: //星期五
%>
<td> </td><td> </td><td> </td><td> </td><td> </td><td>1</td><td>2</td>
<%
z=2;
break;
case 7: //星期六
%> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>1</td>

<% z=1;
break;
}
%>
</tr>
<%
for(int i=1;i<=3;i++)
{
out.println("<tr>");
for(int j=1;j<=7;j++)
{
out.println("<td>"+z+"</td>");
z=z+1;
}
out.println("</tr>");
}
%>
<tr>
<%
switch(TodayLastOfWeek)
{
case 1: //星期天
%>
<td><%=TodayMaxDay%></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<%
break;
case 2: //星期一
%>
<td><%=TodayMaxDay-1%></td>
<td><%=TodayMaxDay%></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<%
break;
case 3: //星期二
%>
<td><%=TodayMaxDay-2%></td>
<td><%=TodayMaxDay-1%></td>
<td><%=TodayMaxDay%></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<%
break;
case 4: //星期三
%>
<td><%=TodayMaxDay-3%></td>
<td><%=TodayMaxDay-2%></td>
<td><%=TodayMaxDay-1%></td>
<td><%=TodayMaxDay%></td>
<td> </td>
<td> </td>
<td> </td>
<%
break;
case 5: //星期四
%>
<td><%=TodayMaxDay-4%></td>
<td><%=TodayMaxDay-3%></td>
<td><%=TodayMaxDay-2%></td>
<td><%=TodayMaxDay-1%></td>
<td><%=TodayMaxDay%></td>
<td> </td>
<td> </td>
<%
break;
case 6: //星期五
%>
<td><%=TodayMaxDay-5%></td>
<td><%=TodayMaxDay-4%></td>
<td><%=TodayMaxDay-3%></td>
<td><%=TodayMaxDay-2%></td>
<td><%=TodayMaxDay-1%></td>
<td><%=TodayMaxDay%></td>
<td> </td>
<%
break;
case 7: //星期六
%>
<td><%=TodayMaxDay-6%></td>
<td><%=TodayMaxDay-5%></td>
<td><%=TodayMaxDay-4%></td>
<td><%=TodayMaxDay-3%></td>
<td><%=TodayMaxDay-2%></td>
<td><%=TodayMaxDay-1%></td>
<td><%=TodayMaxDay%></td>
<%
break;
}
%>
</tr>
</table>
</body>
</html>
回复
lingzi 2002-05-30
不行啊提示错误:Error: Type GregorianCalendar was not found.
回复
weidegong 2002-05-30
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>万年历</title>
<style>
th{color:#FFF;background-color:#F89807}
td{color:#000;background-color:#FDEDCC}
input,textarea,th,td{font-size:9pt}
</style>
</head>
<body>
<div id="hyout"></div>
<script>
//万年历程菜虫制作|-http://happybug.myrice.com
var hy=new Date()
var hyd=new Date()
var cnt=new Array("日","一","二","三","四","五","六")
function hyout(hyy,hym){
var outxt=""
outxt+="<table border=0 width=100% cellspacing=0><tr><th><font color=#FFFFFF>"
outxt+=hym+"月</font>"
outxt+="<table border=0 width=100% cellspacing=1 cellpadding=0><tr align=center>"
for(i=0;i<cnt.length;i++){
outxt+="<td>"+cnt[i]+"</td>"
}
outxt+="</tr><tr align=center>"
var j=0
hyd.setYear(hyy)
hyd.setMonth(--hym)
hyd.setDate(1)
for(var i=1;i<=42;i++){
if((i%7)==1&&i>1)outxt+="</tr><tr align=center>"
if((i<=hyd.getDay())||(hyd.getMonth()!=hym)){
outxt+="<td> </td>"
}else{
hyd.setDate(++j)
if(hyd.getMonth()==hym){
if(hyd.getDate()==hy.getDate()&&hyd.getMonth()==hy.getMonth()&&hyd.getYear()==hy.getYear()){
outxt+="<th>"+j+"</th>"
}else{
outxt+="<td>"+j+"</td>"
}
}else{
outxt+="<td> </td>"
}
}
}
outxt+="</tr></table></th></tr><tr><th></th></tr></table>"
return outxt
}
function hyouty(hyy){
hyy=parseFloat(0+hyy)
if(hyy==0) hyy=hy.getYear()
outxt="<table width=100% border=1 bordercolor=#000000><form><tr><td colspan=4 align=right>公元:<input type=text name=hyyear size=4 maxlength=4 value="+hyy+"> 年 <input type=button value=查看 onclick=hyouty(this.form.hyyear.value)></td></form></tr><tr>"
for(var i=1;i<=12;i++){
if(i%4==1&&i>1)outxt+="</tr><tr>"
outxt+="<td>"+hyout(hyy,i)+"</td>"
}
outxt+="</tr></table>"
document.all["hyout"].innerHTML=outxt
}
hyouty(hy.getYear())
</script>
</body>
</html>
回复
weidegong 2002-05-30
这个用Javascript来实现也可以,不过没有现成的例子,也懒得整理了,原样贴出一个来
回复
lingzi 2002-05-30
不行啊提示错误:Error: Type GregorianCalendar was not found.
回复
chl326 2002-05-30
liuxia
回复
xinry 2002-05-30
还有更好的方法吗?
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告