手机
当前位置:查字典教程网 >编程开发 >JSP教程 >用JSP实现的一个日历程序
用JSP实现的一个日历程序
摘要:日一月二月三月四月五月六月七月八月九月十月十一月十二月年

<>

<%@pagelanguage="java"import="java.util.*"%>

<%!Stringyear;

Stringmonth;

%>

<%month=request.getParameter("month");

year=request.getParameter("year");

%>

<html>

<head>

<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">

<title>日</title>

<scriptLanguage="JavaScript">

<></script>

</head>

<%!Stringdays[];%>

<%

days=newString[42];

for(inti=0;i<42;i++)

{

days[i]="";

}

%>

<%

CalendarthisMonth=Calendar.getInstance();

if(month!=null&&(!month.equals("null")))

thisMonth.set(Calendar.MONTH,Integer.parseInt(month));

if(year!=null&&(!year.equals("null")))

thisMonth.set(Calendar.YEAR,Integer.parseInt(year));

year=String.valueOf(thisMonth.get(Calendar.YEAR));

month=String.valueOf(thisMonth.get(Calendar.MONTH));

thisMonth.setFirstDayOfWeek(Calendar.SUNDAY);

thisMonth.set(Calendar.DAY_OF_MONTH,1);

intfirstIndex=thisMonth.get(Calendar.DAY_OF_WEEK)-1;

intmaxIndex=thisMonth.getActualMaximum(Calendar.DAY_OF_MONTH);

for(inti=0;i<maxIndex;i++)

{

days[firstIndex+i]=String.valueOf(i+1);

}

%>

<body>

<FORMname="sm"method="post"action="calendar.jsp">

<%=year%>年<%=Integer.parseInt(month)+1%>月

<tableborder="0"width="168"height="81">

<divalign=center>

<tr>

<thwidth="25"height="16"bgcolor="#FFFF00"><fontcolor="red">日</font>

</th>

<thwidth="25"height="16"bgcolor="#FFFF00">一</th>

<thwidth="25"height="16"bgcolor="#FFFF00">二</th>

<thwidth="25"height="16"bgcolor="#FFFF00">三</th>

<thwidth="25"height="16"bgcolor="#FFFF00">四</th>

<thwidth="25"height="16"bgcolor="#FFFF00">五</th>

<thwidth="25"height="16"bgcolor="#FFFF00"><fontcolor="green">六</fon

t></th>

</tr>

<%for(intj=0;j<6;j++){%>

<tr>

<%for(inti=j*7;i<(j+1)*7;i++){%>

<tdwidth="15%"height="16"bgcolor="#C0C0C0"valign="middle"align="ce

nter">

<ahref="jump.jsp?year=<%=year%>&month=<%=Integer.parseInt(month)+1%>&d

ate=<%=days[i]%>"target="main"><%=days[i]%></a></td>

<%}%>

</tr>

<%}%>

</div>

</table>

<tableborder="0"width="168"height="20">

<tr>

<tdwidth=30%><selectname="month"size="1"onchange="changeMonth()">

<optionvalue="0">一月</option>

<optionvalue="1">二月</option>

<optionvalue="2">三月</option>

<optionvalue="3">四月</option>

<optionvalue="4">五月</option>

<optionvalue="5">六月</option>

<optionvalue="6">七月</option>

<optionvalue="7">八月</option>

<optionvalue="8">九月</option>

<optionvalue="9">十月</option>

<optionvalue="10">十一月</option>

<optionvalue="11">十二月</option>

</select></td>

<tdwidth=28%><inputtype=textname="year"value=<%=year%>size=4maxlength

=4></td>

<td>年</td>

<tdwidth=28%><inputtype=submitvalue="提交"></td>

</tr>

</table>

</FORM>

<scriptLanguage="JavaScript">

<>

</script>

</body>

</html>

【用JSP实现的一个日历程序】相关文章:

用JSP实现数据库图片的存储与显示实例

jsp实现cookie的使用

JSP上面实现目录压缩

一个用JSP做的日历

JSP 动态树的实现

用JSP编写通用信息发布程序

jsp实现购物程序

实现一个简单的JSP自定义标签开发过程

JSP高访问量下的计数程序

JSP中实现301重定向的代码

精品推荐
分类导航