⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0110.htm

📁 JspServlet教程专栏 对javaservlet讲述的非常详细
💻 HTM
字号:
<html>

<head>
<title>新时代软件教程:操作系统 主页制作 服务器 设计软件 网络技术 编程语言 文字编辑</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
<!--
body, table {font-size: 9pt; font-family: 宋体}
a {text-decoration:none}
a:hover {color: red;text-decoration:underline}
.1  {background-color: rgb(245,245,245)}
-->
</style>
</head>
<p align="center"><script src="../../1.js"></script></a>
    <p align="center"><big><strong>用JSP实现的一个日历程序</strong></big></p>

<div align="right">(文/delighter)</div>

&nbsp;&nbsp;<br>
&lt;!-- File name:calendar.jsp --&gt; <br>
<br>
&lt;!-- 显示任意年、月的日历,可选择不同的年、月。author:wildfield --&gt; <br>
&lt;%@ page language=&quot;java&quot; import=&quot;java.util.*&quot; %&gt; <br>
&lt;%! String year; <br>
&nbsp;&nbsp;&nbsp;String month; <br>
%&gt; <br>
&lt;% month=request.getParameter(&quot;month&quot;); <br>
&nbsp;&nbsp;&nbsp;year =request.getParameter(&quot;year&quot;); <br>
%&gt; <br>
&lt;html&gt; <br>
&lt;head&gt; <br>
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot;&gt; <br>
&lt;title&gt;日&lt;/title&gt; <br>
&lt;script Language=&quot;JavaScript&quot;&gt; <br>
&lt;!-- <br>
function changeMonth() <br>
{ <br>
 var mm=&quot;calendar.jsp?month=&quot;+document.sm.elements[0].selectedIndex+&quot;&amp;year=&quot; <br>
+&lt;%=year%&gt;; <br>
 window.open(mm,&quot;_self&quot;); <br>
} <br>
//--&gt;&lt;/script&gt; <br>
&lt;/head&gt; <br>
&lt;%! String days[]; %&gt; <br>
&lt;% <br>
 days=new String[42]; <br>
 for(int i=0;i&lt;42;i++) <br>
&nbsp;&nbsp;{ <br>
&nbsp;&nbsp;&nbsp;days[i]=&quot;&quot;; <br>
&nbsp;&nbsp;} <br>
%&gt; <br>
&lt;% <br>
 Calendar thisMonth=Calendar.getInstance(); <br>
&nbsp;&nbsp;if(month!=null&amp;&amp;(!month.equals(&quot;null&quot;))) <br>
&nbsp;&nbsp;&nbsp;thisMonth.set(Calendar.MONTH, Integer.parseInt(month) ); <br>
&nbsp;&nbsp;if(year!=null&amp;&amp;(!year.equals(&quot;null&quot;))) <br>
&nbsp;&nbsp;&nbsp;thisMonth.set(Calendar.YEAR, Integer.parseInt(year) ); <br>
&nbsp;&nbsp;year=String.valueOf(thisMonth.get(Calendar.YEAR)); <br>
 month=String.valueOf(thisMonth.get(Calendar.MONTH)); <br>
 thisMonth.setFirstDayOfWeek(Calendar.SUNDAY); <br>
 thisMonth.set(Calendar.DAY_OF_MONTH,1); <br>
 int firstIndex=thisMonth.get(Calendar.DAY_OF_WEEK)-1; <br>
 int maxIndex=thisMonth.getActualMaximum(Calendar.DAY_OF_MONTH); <br>
 for(int i=0;i&lt;maxIndex;i++) <br>
&nbsp;&nbsp;{ <br>
&nbsp;&nbsp;&nbsp;days[firstIndex+i]=String.valueOf(i+1); <br>
&nbsp;&nbsp;} <br>
%&gt; <br>
&lt;body&gt; <br>
&lt;FORM name=&quot;sm&quot; method=&quot;post&quot; action=&quot;calendar.jsp&quot;&gt; <br>
&nbsp;&nbsp;&nbsp;&lt;%=year%&gt;年&nbsp;&nbsp;&lt;%=Integer.parseInt(month)+1%&gt;月 <br>
&lt;table border=&quot;0&quot; width=&quot;168&quot; height=&quot;81&quot;&gt; <br>
&lt;div align=center&gt; <br>
&nbsp;&nbsp;&lt;tr&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;th width=&quot;25&quot; height=&quot;16&quot; bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;red&quot;&gt;日&lt;/font&gt; <br>
&lt;/th&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;th width=&quot;25&quot; height=&quot;16&quot; bgcolor=&quot;#FFFF00&quot;&gt;一&lt;/th&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;th width=&quot;25&quot; height=&quot;16&quot; bgcolor=&quot;#FFFF00&quot;&gt;二&lt;/th&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;th width=&quot;25&quot; height=&quot;16&quot; bgcolor=&quot;#FFFF00&quot;&gt;三&lt;/th&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;th width=&quot;25&quot; height=&quot;16&quot; bgcolor=&quot;#FFFF00&quot;&gt;四&lt;/th&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;th width=&quot;25&quot; height=&quot;16&quot; bgcolor=&quot;#FFFF00&quot;&gt;五&lt;/th&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;th width=&quot;25&quot; height=&quot;16&quot; bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;green&quot;&gt;六&lt;/fon <br>
t&gt;&lt;/th&gt; <br>
&nbsp;&nbsp;&lt;/tr&gt; <br>
&lt;% for(int j=0;j&lt;6;j++) { %&gt; <br>
 &lt;tr&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;% for(int i=j*7;i&lt;(j+1)*7;i++) { %&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;15%&quot; height=&quot;16&quot; bgcolor=&quot;#C0C0C0&quot; valign=&quot;middle&quot; align=&quot;ce <br>
nter&quot;&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;a href=&quot;jump.jsp?year=&lt;%=year%&gt;&amp;month=&lt;%=Integer.parseInt(month)+1%&gt;&amp;d <br>
ate=&lt;%=days[i]%&gt;&quot; target=&quot;main&quot;&gt;&lt;%=days[i]%&gt;&lt;/a&gt;&lt;/td&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;% }&nbsp;&nbsp;%&gt; <br>
&nbsp;&nbsp;&lt;/tr&gt; <br>
&lt;% }&nbsp;&nbsp;%&gt; <br>
&lt;/div&gt; <br>
&lt;/table&gt; <br>
&lt;table border=&quot;0&quot; width=&quot;168&quot; height=&quot;20&quot;&gt; <br>
 &lt;tr&gt; <br>
&nbsp;&nbsp;&lt;td width=30%&gt;&lt;select name=&quot;month&quot; size=&quot;1&quot; onchange=&quot;changeMonth()&quot; &gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;0&quot;&gt;一月&lt;/option&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;1&quot;&gt;二月&lt;/option&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;2&quot;&gt;三月&lt;/option&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;3&quot;&gt;四月&lt;/option&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;4&quot;&gt;五月&lt;/option&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;5&quot;&gt;六月&lt;/option&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;6&quot;&gt;七月&lt;/option&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;7&quot;&gt;八月&lt;/option&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;8&quot;&gt;九月&lt;/option&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;9&quot;&gt;十月&lt;/option&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;10&quot;&gt;十一月&lt;/option&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value=&quot;11&quot;&gt;十二月&lt;/option&gt; <br>
&nbsp;&nbsp;&lt;/select&gt;&lt;/td&gt; <br>
 &lt;td width=28%&gt;&lt;input type=text name=&quot;year&quot; value=&lt;%=year%&gt; size=4 maxlength <br>
=4&gt;&lt;/td&gt; <br>
 &lt;td&gt;年&lt;/td&gt; <br>
 &lt;td width=28%&gt;&lt;input type=submit value=&quot;提交&quot;&gt;&lt;/td&gt; <br>
 &lt;/tr&gt; <br>
&lt;/table&gt; <br>
&lt;/FORM&gt; <br>
&lt;script Language=&quot;JavaScript&quot;&gt; <br>
&lt;!-- <br>
&nbsp;&nbsp;document.sm.month.options.selectedIndex=&lt;%=month%&gt;; <br>
//--&gt; <br>
&lt;/script&gt; <br>
&lt;/body&gt; <br>
&lt;/html&gt;&nbsp;&nbsp;<br>
<br>
 <br>
</p>

  </table>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -