|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
在性能方面,在windows平台下,.net可能是占强项,要是把.net放在sun开发的操作系统上去运行呢?根本就运行不了,.net对其它操作系统的支持也很弱,性能也可能比不上java。js|网页在JSP网页上完成月历
JSP、月历
<%@pagecontentType="text/html;charset=gb2312"language="java"import="java.util.*,java.text.*"%>
<html>
<head>
<title>月历</title>
</head>
<bodystyle="font-size:12px">
<%!
/*声明变量*/
String[]months={"January","February","March","April","May","June",
"July","August","September","October","November","December"};
String[]months_cn={"一月","仲春","三月","四月","蒲月","六月",
"七月","八月","玄月","十月","十一月","十仲春"};
publicfinalstaticintdom[]={
31,28,31,30,
31,30,31,31,
30,31,30,31
};
%>
<%
/*处置事务*/
booleanyyok=false;
intyy=0,mm=0;
StringyyString=request.getParameter("year");
if(yyString!=null&&yyString.length()>0){
try{
yy=Integer.parseInt(yyString);
yyok=true;
}
catch(NumberFormatExceptione){
out.println("年份不成用");
}
Calendarcal=Calendar.getInstance();
if(!yyok)
yy=cal.get(Calendar.YEAR);
StringmmString=request.getParameter("month");
if(mmString==null){
mm=cal.get(Calendar.MONTH);
}
else{
for(inti=0;i<months.length;i++)
if(months[i].equals(mmString)){
mm=i;
break;
}
}
}
%>
<formname="cal"method=postaction="cal.jsp">
请选择月份:
<selectname="month">
<%
/*初始化表单*/
for(inti=0;i<months.length;i++){
if(i==mm)
out.print("<optionselectedvalue=January>");
else
out.print("<optionvalue="+months[i]+">");
out.print(months_cn[i]);
out.print("</option>");
}
%>
</select>
<br>请输出年份:
<inputtype="text"size="5"name="year"value="<%=yy%>">
<inputtype="submit"value="显现">
</form>
<%
intlead=0;
%>
<tableborder="0"cellpadding="1"cellspacing="1"style="font-size:12px">
<trheight="20"><tdcolspan="7"><fontcolor="#3399FF"><b><%=months[mm]%><%=yy%></b></font></td></tr>
<%GregorianCalendarcalendar=newGregorianCalendar(yy,mm,1);%>
<tr><td><fontcolor="#FF0000">Sun</font></td><td>Mon</td><td>Tue</td><td>Wed</td>
<td>Thu</td><td>Fri</td><td><fontcolor="#FF0000">Sat</font></td></tr>
<%
/*上面是显现月历的代码*/
lead=calendar.get(Calendar.DAY_OF_WEEK)-1;
intdayInMonth=dom[mm];
if(calendar.isLeapYear(calendar.get(Calendar.YEAR))&&mm==1)
++dayInMonth;
out.print("<tr>");
for(inti=0;i<lead;i++){
out.print("<td></td>");
}
for(inti=1;i<=dayInMonth;i++){
if((i+lead)%7==0||(i+lead)%7==1)
out.print("<tdalign="center"><fontcolor="#FF0000">"+i+"</font></td>");
else
out.print("<tdalign="center">"+i+"</td>");
if((lead+i)%7==0){
out.print("</tr></tr>");
}
}
out.print("</tr>");
%>
</table>
</body>
</html>
首先java功能强大的背后是其复杂性,就拿web来说,当今流行的框架有很多,什么struts,spring,jQuery等等,而这无疑增加了java的复杂性。 |
|