打印本文 打印本文  关闭窗口 关闭窗口
jsp留言板源代码二: 给jsp初学者.
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005/9/10 14:26:40
);
}
rcount.close();
} catch (Exception el1) { out.println("count record error
: "+el1+"<br>" );
out.println(countsql);
}

totalpages=(int)(count/pagesize);
if(count>totalpages*pagesize) totalpages++;
st=""+
" <TABLE align=center border=0 cellPadding=0 cellSpacing=
0 width="95%"> "+
" <TBODY> <TR> <TD align=middle bgColor=#97badd width="1
00%"><FONT color=#ff0000>"+
" 共 "+totalpages+" 页,"+count+"
条. "+" 当前页: "+pages+
" </FONT></TD></TR></TBODY></TABLE><BR> ";

out.print(st);

//out.print(" 共 "+totalpages+" 页,"+
count+" 条. "+" 当前页: "+pages+"<br>");

st=" <center> "+
" <TABLE border=0 cellPadding=2 cellSpacing=1 width="95%"> "+
" <TBODY> "+
" <TR> "+
" <TD align=middle bgColor=#6699cc width="55%"><FONT "+
" color=#ffffff>留言主题</FONT></TD> "+
" <TD align=middle bgColor=#6699cc width=50><FONT "+
" color=#ffffff>回应数</FONT></TD> "+
" <TD align=middle bgColor=#6699cc width=40><FONT "+
" color=#ffffff>点击数</FONT></TD> "+
" <TD align=middle bgColor=#6699cc width=100><FONT "+
" color=#ffffff>作者名</FONT></TD> "+
" <TD align=middle bgColor=#6699cc width=140><FONT "+
" color=#ffffff>发表/回应时间</FONT></TD></TR> ";
out.print(st);

if(count > 0 )
{
ResultSet rs = testInq.executeQuery(inqsql);
ResultSetMetaData metaData = rs.getMetaData();

int i;
// 跳过pages -1 页,使cursor指向pages并准备显示
for(i=1;i<=(pages - 1)*pagesize;i++) rs.next();
//显示第pages页开始
String linestr="";
for(i=1;i<=pagesize;i++)
if(rs.next())
{
lw_title=rs.getString("lw_title");
answer_num=rs.getInt("answer_num");
click_num=rs.getInt("click_num");
lw_author=rs.getString("lw_author");
lw_time=rs.getString("lw_time");
st=lw_time.substring(0,4)+"-"+lw_time.substring(4,6)+"-"
+lw_time.substring(6,8)+":"+
lw_time.substring(8,10)+":"+lw_time.substring(10,12)+
":"+lw_time.substring(12,14);
lw_ico=rs.getString("expression");
author_email=rs.getString("author_email");
lw_class1=rs.getString("lw_class1");
lw_class2=rs.getString("lw_class2");
llink="reply.jsp?lw_class1="+lw_class1+"&lw_class2="+lw_
class2+"&zt_time="+lw_time+
"&zt_author="+author_email;
linestr=" <TR bgColor=#d5e8fd> " +
" <TD bgColor=#d5e8fd><IMG src=""+lw_ico+".gif
"><A "+
" href=""+llink+" ">"+lw_title+"</A></TD> "+
" <TD align=middle>["+answer_num+"]</TD>"+
" <TD align=middle>"+click_num+"</TD>"+
" <TD align=middle><A href="mailto:"+author_ema
il+"">"+lw_author+"</A></TD>"+
" <TD align=middle>"+st+"</TD></TR>";

out.println(linestr);

}
rs.close();
//显示第pages页结束
st="</TBODY></TABLE><BR>";
out.print(st);

int iFirst=1,iLast=totalpages,iPre,iNext;
if(pages<=1) iPre=1;
else iPre=pages - 1;

if(pages>=totalpages) iNext=totalpages;
else iNext=pages + 1;

int n=(int)(count/pagesize);
if(n*pagesize<count) n++;
if(n>1)
{
//for(i=1;i<=n;i++) out.print("<a href=inquire.jsp?pages=
"+i+">"+i+" </a>");
//out.print("<HR align=center noShade SIZE=1 width="95%
">");
String lt1="返回主页",lt2="第一页",lt3="上一页",lt4="下一
页",lt5="最后一页",lt6="";
lt6="<a href=http://www.zj.hn.cn>"+ lt1 + " </
a>"+
lurlt + "pages="+iFirst+"><FONT color=red>"+lt2+"&nbs
p; </a>"+
lurlt + "pages="+iPre+"><FONT color=red>"+lt3+"
</a>" +
lurlt + "pages="+iNext+"><FONT color=red>"+lt4+"
; </a>" +
lurlt + "pages="+iLast+"><FONT color=red>"+lt5+"
; </a>";
st=""+
" <TABLE align=center border=0 cellPadding=0 cellSpacing=
0 width="95%"> "+
" <TBODY> <TR> <TD align=middle bgColor=#97badd width="1
00%"><FONT color=#ff0000>"+
lt6+
" </FONT></TD></TR></TBODY></TABLE><BR> ";

out.print(st);

}

}
} catch (Exception e) { out.println("error: "+e); }
}


%>


<%
//留言板界面尾部
String lbottom="";
lbottom=lbottom+
" "+
" <FORM action=guestbook.jsp method=post name=sign> "+
" <INPUT name=gbname type=hidden value=cnzjj_gt> "+
" <INPUT name=pages type=hidden value=1> "+
" <TABLE bgColor=#d5e8fd border=0 cellSpacing=1 width="95%"> "+

" <TBODY> "+
" <TR> "+
" <TD align=middle bgColor=#e6e6fa colSpan=2 noWrap><STRONG><FONT
color=blue "+
" face=楷体_GB2312 size=5>发 表 意 见</FONT></STRONG> &nbs
p; [加*的内容必须填写] </TD></TR> "+
" <TR> "+
" <TD noWrap width="45%"> "+
" <DIV align=left> "+
" <TABLE bgColor=#d5e8fd border=0 cellSpacing=1 width="100%">
"+
" <TBODY> "+
" <TR> "+
" <TD noWrap width="100%">*留言主题:<INPUT maxLength=40 n
ame=lw_title "+
" size=36></TD></TR> "+
" <TR> "+
" <TD noWrap width="100%">*网上大名:<INPUT maxLength=18 n
ame=lw_author "+
" size=36></TD></TR> "+
" <TR> "+
" <TD noWrap width="100%"> 主页标题:<INPUT maxLength
=40 name=pagetitle "+
" size=36></TD></TR> "+
" <TR> "+
" <TD noWrap width="100%"> 主页地址:<INPUT maxLength
=255 name=author_http "+
" size=36></TD></TR> "+
" <TR> "+
" <TD noWrap width="100%">*电子邮件:<INPUT maxLength=40 n
ame=author_email "+
" size=36></TD></TR></TBODY></TABLE></DIV></TD> "+
" <TD noWrap vAlign=top width="55%"> "+
" <DIV align=left> "+
" <TABLE bgColor=#b6d7fc border=0 cellSpacing=1 width="100%">
"+
" <TBODY> "+
" <TR> "+
" <TD width="100%">请在下面填写你的留言:</TD></TR> "+

" <TR> "+
" <TD width="100%"><TEXTAREA cols=50 name=lw_content rows=
7></TEXTAREA></TD></TR></TBODY></TABLE></DIV></TD></TR> "+
" <TR> "+
" <TD bgColor=#fbf7ea colSpan=2 noWrap>表情 "+
" <INPUT name=gifface type=radio value=1 checked><IMG "+
" alt="1.gif (152 bytes)" height=15 src="1.gif" width=15> <I
NPUT "+
" name=gifface type=radio value=2><IMG alt="2.gif (174 bytes)"
height=15 "+
" src="2.gif" width=15> <INPUT name=gifface type=radio value=3
><IMG "+
" alt="3.gif (147 bytes)" height=15 src="3.gif" width=15> <I
NPUT "+
" name=gifface type=radio value=4><IMG alt="4.gif (172 bytes)"
height=15 "+
" src="4.gif" width=15> <INPUT name=gifface type=radio value=5
><IMG "+
" alt="5.gif (118 bytes)" height=15 src="5.gif" width=15> <I
NPUT "+
" name=gifface type=radio value=6><IMG alt="6.gif (180 bytes)"
height=15 "+
" src="6.gif" width=15> <INPUT name=gifface type=radio value=7
><IMG "+
" alt="7.gif (180 bytes)" height=15 src="7.gif" width=15> <I
NPUT "+
" name=gifface type=radio value=8><IMG alt="8.gif (96 bytes)"
height=15 "+
" src="8.gif" width=15> <INPUT name=gifface type=radio value=9
><IMG "+
" alt="9.gif (162 bytes)" height=15 src="9.gif" width=15> <I
NPUT "+
" name=gifface t

上一页  [1] [2] [3]  下一页



打印本文 打印本文  关闭窗口 关闭窗口