基于JSP的网上留言系统的设计与实现 第6页

基于JSP的网上留言系统的设计与实现 第6页
具体代码如下所示。
<%
  String sql="select * from Guestbook order by id DESC";
  ResultSet Rs=stmt.executeQuery(sql);
  int intPageSize; //一页显示的记录数
  int intRowCount; //记录总数
  int intPageCount; //总页数
  int intPage; //待显示页码
  String  strPage;
  int i;
 
//设置一页显示的记录数
 intPageSize = 2;

//取得待显示页码
strPage = request.getParameter("page");
if(strPage==null){//表明在QueryString中没有page这一个参数,此时显示第一页数据
  intPage = 1;
  } else{//将字符串转换成整型
intPage = java.lang.Integer.parseInt(strPage);
if(intPage< 1) intPage = 1;
}
//获取记录总数
Rs.last();
intRowCount = Rs.getRow();
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码
if(intPage >intPageCount) intPage = intPageCount;
if(intPageCount >0){
//将记录指针定位到待显示页的第一条记录上
Rs.absolute((intPage-1) * intPageSize+1);
//显示数据
%>
<DIV id=Tbody>
<DIV id=mainContent>
<DIV id=innermainContent>
<DIV id=mainContent-topimg></DIV>
<DIV class=content-width id=Content_Contentlist>
<DIV class=pageContent>
<DIV class=page style="FLOAT: right">
<UL>
  </UL></DIV></DIV>
<%
i = 0;
while(i< intPageSize && !Rs.isAfterLast()){
//读留言信息
int id=Rs.getInt("id");
String username=Rs.getString("username");
String userface=Rs.getString("userface");
String userurl=Rs.getString("userurl");
String usermail=Rs.getString("usermail");
String userqq=Rs.getString("userqq");
String usertitle=Rs.getString("usertitle");
String content=Rs.getString("content");
String mydate=Rs.getString("mydate");
String remydate=Rs.getString("remydate");
String recontent=Rs.getString("recontent");
String ip=Rs.getString("ip");
%>      
<DIV class=Content>
  <DIV class=comment style="MARGIN-BOTTOM: 20px">
<DIV class=commenttop><IMG style="MARGIN: 0px 1px -3px 0px"
alt=公开 src="images/qipeng/icon_quote.gif" border=0> <B><%=username%></B>
</DIV>
www.751com.cn
        <td width="140" align="center" valign="top" bgcolor="#CCCCCC" ><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height=20></td>
            </tr>
          </table>
            <img src="images/<%=userface%>.gif" width="72" height="72"><br>
            <br>
            <%=username%>&nbsp;</td>
        <td valign="top"><table width="100%" border="0" align="center" cellpadding="1" cellspacing="3">
            <tr>
              <td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#999999">
                  <tr>
                    <td bgcolor="#FFFFFF"><table width="100%" height="24" border="0" cellpadding="0" cellspacing="0" bgcolor="#f5f5f5">
                        <tr>
                          <td width="50%" bgcolor="#CCCCCC">&nbsp;标题:<%=usertitle%>&nbsp;</td>
                          <td width="50%" bgcolor="#CCCCCC"><div align="right"> <a href="<%=userurl%>" target="_blank"><img src="images/home.gif" width="16" height="16" border="0" align="absmiddle" alt="主页:[ <%=userurl%> ]"></a> | <a href="mailto:<%=usermail%>" target="_blank"><img src="images/email.gif" width="18" height="18" border="0" align="absmiddle" alt="电子邮件:[ <%=usermail%> ]"></a> | <a href="#"><img src="images/qq-gray.gif" width="16" height="16" border="0" align="absmiddle" alt="QQ号码:<%=userqq%>"></a> | <a href="#"><img src="images/ip.gif" width="16" height="16" border="0" align="absmiddle" alt="来自:[ <%=ip%> ]"></a> &nbsp; </div></td>
                        </tr>
                    </table></td>
                  </tr>
              </table></td>
            </tr>
          </table>
            <table width="100%" height="100%" border="0" cellpadding="1" cellspacing="5">
              <tr>
                <td bgcolor="#999999"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td bgcolor="#CCCCCC"><fieldset style="width:100%;" align="center;">
                        <legend> &nbsp;<strong>留言内容: </strong></legend>
                        <table width="100%" border="0" cellspacing="4" cellpadding="0">
                          <tr>
                            <td height="60"><%=content%></td>

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有