|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
但是对于JAVA技术类的学习,我觉得大课堂反而会影响自身独立思考的过程,因为上课的时候,老师讲课的速度很快为了不遗漏要点,通常会仔细的听,js|web|程序|日历一个JSP+JAVABEANS完成的WEB日过程序,次要利用了Calendar类!
monthBean.java
packagetest;
importjava.text.DateFormat;
importjava.text.DateFormatSymbols;
importjava.util.*;
publicclassmonthBean{
publicfinalstaticint[]DAYSINMONTH={31,28,31,30,31,30,31,31,30,31,30,31};
publicString[]monthNames=null;
protectedDateFormatSymbolssymbols=null;
protectedCalendarcal=Calendar.getInstance();
protectedinttoday=cal.get(Calendar.DAY_OF_MONTH);
protectedintmonth=cal.get(Calendar.MONTH);
protectedintyear=cal.get(Calendar.YEAR);
publicmonthBean(){
symbols=newDateFormatSymbols();
monthNames=symbols.getMonths();
}
publicvoidsetMonth(intmonthArg){
this.month=monthArg;
}
publicvoidsetYear(intyearArg){
this.year=yearArg;
}
publicvoidsetMonth(StringmonthArg){
try{
intmonth=Integer.parseInt(monthArg);
setMonth(month);
}catch(Exceptionexc){
}
}
publicvoidsetYear(StringyearArg){
try{
intyear=Integer.parseInt(yearArg);
setYear(year);}catch(Exceptionexc){
}
}
publicStringgetMonthName(){
returnmonthNames[cal.get(Calendar.MONTH)];
}
publicintgetToday(){
returntoday;
}
publicintgetStartCell(){
CalendarbeginOfMonth=Calendar.getInstance();
beginOfMonth.set(year,month,0);
returnbeginOfMonth.get(Calendar.DAY_OF_WEEK);
}
publicintgetEndCell(){
cal.set(year,month,1);intendCell=DAYSINMONTH[month]+getStartCell()-1;
if(month==Calendar.FEBRUARY&&((GregorianCalendar)cal).isLeapYear(year)){
endCell++;
}
returnendCell;
}
publicvoidupdate(){
cal.set(this.year,this.month,1);
}
publicStringgetDayName(intday,booleanlongFormat){
if(longFormat)
returnsymbols.getWeekdays()[day];
returnsymbols.getShortWeekdays()[day];
}
}
month.jsp
<%@pagecontentType="text/html;charset=gb2312"%>
<%@pageimport="test.monthBean"%>
<jsp:useBeanid="cal"class="test.monthBean"scope="request"/>
<%
inttoday=cal.getToday();
%>
<html>
<head>
<title>
日历
</title>
</head>
<bodybgcolor="silver"><br><br><br>
<tableborder="1"align="center"width="40%"height="100"><trbgcolor="silver">
<tdcolspan="7"><fontsize="+2">
<%=cal.getMonthName()%>
</font></td></tr>
<trbgcolor="black"align="center">
<%for(inti=1;i<8;i++){
out.print("<tdwidth="70">");
out.print("<fontsize"-1"color="white">");
out.print(cal.getDayName(i,true));
out.print("</front></td>");
}%>
</tr>
<%intstartcell=cal.getStartCell();
intendcell=cal.getEndCell();
for(intcellNo=0,day=1;cellNo<42;cellNo++){
if(cellNo%7==0){out.print("<tr>");}
out.print("<tdvalign=topheight=57");
if(cellNo<startcell||cellNo>endcell){
out.print("bgcolor="gray">");}
else{
if(day==today){//假如为以后日期,背景致设为绿色
out.print("bgcolor="green">");
}
else
out.print(">");
%>
<%=day%>
<%
day++;
}
out.println("</td>");
if(cellNo+1%7==0){
out.print("</tr>");}
}//endforloop
%>
</table>
</body>
</html>
关于第二点:俺问问你,如果是企业级项目的话,诸如RMI,EJB,等一些关键技术,这些难道都不需要学么?如果光是使用jsp,servlet,javabean的话。 |
|