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

📄 index.jsp~108~

📁 网吧网站留言本。主要使用基于MVC模式的JSP+JAVABEAN+SERVLET
💻 JSP~108~
字号:
<jsp:include flush="true" page="top.htm"/>
<%@page contentType="text/html; charset=GBK"%>
<jsp:useBean id="gbdao" scope="page" class="com.netbar.dao.gbDao"/>
<jsp:useBean id="gbcd" scope="page" class="com.netbar.dao.gbCountDao"/>
<%
session.setAttribute("logined","OK");
%>
<%
//每登陆一次计数器累加一
gbcd.updateCountWhenEnter();
%>
<%
//更新管理员最后登陆时间(if实现,只是登陆第一次进入页面时实现更新)。。。
if(session.getAttribute("logined")!=null && session.getAttribute("timeUpdated")==null){
  gbcd.updateTimeWhenLogin();
  session.setAttribute("timeUpdated","true");
}

%>
<%
  //添加分页
  int currentPage = 1; //当前页,初始为1
  int recordRows = 10; //每页记录行数
  int pageSize = 0; //总页数
  int totalRecords = com.netbar.dao.gbDao.getgbRecords();
  //计算取得总页数
  if (totalRecords % recordRows == 0) {
    pageSize = totalRecords / recordRows;
  }
  else {
    pageSize = (totalRecords / recordRows) + 1;
  }
  String tempPage = request.getParameter("currentPage");
  if (tempPage != "" && tempPage != null) {
    currentPage = Integer.parseInt(tempPage);
  }
  String goPage = request.getParameter("goPage");
  if (goPage != null) {
    if (!goPage.equals("")) {
      currentPage = Integer.parseInt(goPage);
    }
  }
  //确认各页的起始和结束留言记录
  int startRecord = recordRows*(currentPage - 1);
  int stopRecord = startRecord + recordRows;
  if (currentPage == pageSize) {
    stopRecord = totalRecords;
  }
%>

<%if (currentPage > pageSize) {%>
<script type="text/javascript">
  alert("超过当前最多页数!");
  </script><%
  currentPage = 1;
  startRecord = 0;
  stopRecord = recordRows;
  }
%>
<%if (currentPage < 1) {%>
<script type="text/javascript">
  alert("您要查找的页数不能低于1!!!");
  </script><%
  currentPage = 1;
  startRecord = 0;
  stopRecord = recordRows;
  }
%>
<html>
<head>
<title>中青网络会所>>留言本</title>
<meta name="Robots" content="all">
<meta name="Generator" content="Dreamweaver,ASP">
<meta name="copyright" content="Copyright 中青网络会所 2007-2008">
<meta name="Author" content="zqnet">
<meta name="description" content="中青网络会所留言本">
<meta name="keywords" content="留言本,中青">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css.css" rel="stylesheet" type="text/css">
<%--SCRIPT Language="JScript" SRC="xp_ubbcode.js" Runat=Server></SCRIPT--%>
<style type="text/css">
  <!--
    .style14 {color: #666666}
    .style16 {
    color: #0099FF;
    font-weight: bold;
    }
  -->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script><script type="text/javascript" language="javascript">
function check(){
  gopage=this.go.goPage.value;
  if(gopage==""){
    alert("请输入您要跳转到的页面。");
    this.go.goPage.focus();
    return false;
  }else{
    return true;
  }
}
</script></head>
<body background="images/bg_001.gif" bgproperties="fixed">
<table width="680" height="12" border="0" align="center" cellpadding="0" cellspacing="0" class="biao_bdr">
  <tr>
    <td>
      <img src="images/bar_1.gif" width="678" height="20">
    </td>
  </tr>
</table>
<%
session.setAttribute("logined","OK");
%>
<%
  com.netbar.bean.gbBean[] gbbeans = gbdao.getAlldata();
  //System.out.println(gbbeans.length);
  //String title,content,reply,person,web,mail,qq,face,ip,pcname,time,redate;
  //int id;
  for (int i = startRecord ,j=1; i < stopRecord; i++,j++) {
    int id = gbbeans[i].getGbID();
    String title = gbbeans[i].getGbTitle();
    String content = gbbeans[i].getGbContent();
    String reply = gbbeans[i].getGbReply();
    String person = gbbeans[i].getGbPerson();
    String web = gbbeans[i].getGbWeb();
    String mail = gbbeans[i].getGbMail();
    String qq = gbbeans[i].getGbQQ();
    String face = gbbeans[i].getGbFace();
    String ip = gbbeans[i].getGbIP();
    String pcname = gbbeans[i].getGbPcname();
    String time = gbbeans[i].getGbTime();
    String redate = gbbeans[i].getGbRedate();
    //System.out.println(!reply.equals("暂无回复") + "\n\n\n\n\n");
%>
<table width="680" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#EBF2F8" class="biao_bdr" style="table-layout:fixed;word-break:break-all">
  <tr>
    <td width="140" rowspan="2" style="border-right: 1px solid #d1e0f0;">
      <table width="98%" height="35" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td>
            <div align="center">
              <font style="FONT-SIZE: 10pt; FILTER: shadow(color=#C0C0C0); COLOR: #000000; HEIGHT: 1px"><%=person%>              </font>
            </div>
          </td>
        </tr>
      </table>
      <div align="center">
        <%
       if(!face.equals("images/admin.gif")){

       %>
       <img width="64" height="64" src="<%=face%>" alt="【<%=person%>】的ID为:<%=id%>">
        <%}else{
        %>
        <img width="128" height="128" src="<%=face%>" alt="【<%=person%>】的ID为:<%=id%>">
       <% }%>
        <br>
      </div>
      <div align="center">
        <table width="125" height="28" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td>
              <div align="center">
              <%if (qq.trim().length() != 0 && qq != null) {              %>
                <img src="images/oicq.gif" alt="QQ:<%=qq%>" width="16" height="16">
              <%}              %>
              <%if (session.getAttribute("logined") != null) {              %>
                <img src="images/icon_ip.gif" alt="计算机名:<%=pcname%>" width="13" height="15">
              <%} else {              %>
                <img src="images/icon_ip.gif" alt="IP:<%=ip%>" width="13" height="15">
              <%}              %>
              <%if ((!mail.equals("")) && mail != null) {              %>
                <a href="mailto:<%=mail%>">
                  <img src="images/email.gif" alt="邮箱:<%=mail%>" width="16" height="16" border="0">
                </a>
              <%}              %>
              <%if (!web.equals("") && (!web.equals("http://")) && web != null) {              %>
                <a href="<%=web%>" target="_blank">
                  <img src="images/homepage.gif" alt="个人主页:<%=web%>" width="16" height="16" border="0">
                <%}                %>
                  <br>
                </a>
              </div>
            </td>
          </tr>
        </table>
      </div>
      <div align="center">
        <table width="96" border="0" cellspacing="0" cellpadding="0" style="table-layout:fixed;word-break:break-all">
          <tr>
            <td style="padding:4px;word-wrap: break-word">            </td>
          </tr>
        </table>
      </div>
    </td>
    <td>
      <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td>            &nbsp;
            <strong>
              <%
              String imgsrc="";
             if(j<10){
               imgsrc="images/0"+j+".gif";
             }else{
               imgsrc="images/"+j+".gif";
             }
              %>
              <img alt="当前页中第<%=j%>条留言记录" src="<%=imgsrc%>" />
              <img src="images/more01.gif" width="15" height="14" border="0" align="middle">
<%=title %>            </strong>
            <table width="520" height="1" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#d1e0f0">
              <tr>
                <td>                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table width="540" height="120" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="40">
            <table width="520" height="50" align="center" cellspacing="0" cellpadding="0" border="0" style="table-layout:fixed;word-break:break-all">
              <tbody>
                <tr>
                  <td style="padding:4px;word-wrap: break-word">                    &nbsp;
                    <font style="FONT-SIZE: 10pt; FILTER: shadow(color=#C0C0C0); COLOR: #000000; HEIGHT: 1px"><%=content%>                    </font>
                  </td>
                </tr>
              </tbody>
            </table>
          </td>
        </tr>
        <tr>
          <td>
            <div align="right">
            <%if (session.getAttribute("logined").toString().toUpperCase().equals("OK")) {%>
              <a href="res.jsp?id=<%=id%>" target="_self" style="color:red">回复</a>
              |
              <a href="del.jsp?id=<%=id%>" style="color:red">删除</a>
              &nbsp;
            <%} %>
              [
              <strong><%=time%>              </strong>
              ]
              &nbsp;
            </div>
          </td>
        </tr>
        <tr>
          <td>
            <p style="color: #0033CC">
              <font style="FONT-SIZE: 10pt; FILTER: shadow(color=#c0c0c0); COLOR: blue; HEIGHT: 1px">
              <%if (reply!=null && !reply.equals("暂无回复")) {           %>
                &nbsp;
                <img src="images/bb01.gif" width="21" height="14" border="0" align="absmiddle">
                中青回复:
<%=reply%>              </font>
            </p>
            <p style="color: #0033CC">&nbsp;</p>
            <p align="right" style="color: #0033CC">
              <font style="FONT-SIZE: 10pt; FILTER: shadow(color=#c0c0c0); COLOR: blue; HEIGHT: 1px">                回复日期:【
<%=redate%>                】
                &nbsp;
                <br>
              <%}              %>
              </font>
            </p>
            <p style="color: #0033CC">&nbsp;</p>
            <div align="right">            </div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<%}%>

<table width="680" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#66CCFF" class="biao_bdr">
  <tr>
    <form action="#" name="go" method="POST" onsubmit="return check();">
    <td align="center">

             总计
<%=totalRecords%>        条
        &nbsp;
        共有
<%=currentPage%>        /
<%=pageSize%>        页
        &nbsp;
        每页
<%= recordRows %>        条
        &nbsp;
      <%if (currentPage != 1) {      %>
        <a href="index.jsp">首页</a>
        <a href="index.jsp?currentPage=<%=currentPage-1%>">上一页</a>
        &nbsp;
      <%}      %>
      <%if (currentPage != pageSize) {      %>
        <a href="index.jsp?currentPage=<%=currentPage+1%>">下一页</a>
        &nbsp;
        <a href="index.jsp?currentPage=<%=pageSize%>">尾页</a>
      <%}      %>

        <input type="text" size="2" name="goPage"/>
        <input value="Go!" name="confirm" type="submit"/>

    </td>
     </form>
  </tr>
</table>

<jsp:include flush="true" page="buttom.jsp"/>
</body>
</html>

⌨️ 快捷键说明

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