濮阳杆衣贸易有限公司

主頁 > 知識庫 > jsp頁面數(shù)據(jù)分頁模仿百度分頁效果(實例講解)

jsp頁面數(shù)據(jù)分頁模仿百度分頁效果(實例講解)

熱門標(biāo)簽:自繪地圖標(biāo)注數(shù)據(jù) 如何看懂地圖標(biāo)注點 給地圖標(biāo)注得傭金 外呼系統(tǒng)使用方法 潤滑油銷售電銷機(jī)器人 海外圖書館地圖標(biāo)注點 電銷機(jī)器人免培訓(xùn) 南通通訊外呼系統(tǒng)產(chǎn)品介紹 電話機(jī)器人需要使用網(wǎng)絡(luò)嗎

廢話不多說,直接上代碼

請根據(jù)自己的項目、包名修改

%@page import="web09.shop.DBUtil"%>
%@page import="java.sql.ResultSet"%>
%@page import="java.sql.PreparedStatement"%>
%@page import="java.sql.Connection"%>
%@ page language="java" pageEncoding="UTF-8"%>
!DOCTYPE html>
html>
head>
  meta charset="UTF-8">
  title>數(shù)據(jù)分頁/title>
  style type="text/css">
    .page a{
      min-width: 34px;
      height: 34px;
      border: 1px solid #e1e2e3;
      cursor: pointer;
      display:block;
      float: left;
      text-decoration: none;
      text-align:center;
      line-height: 34px;      
    }
    
    .page a:HOVER {
      background: #f2f8ff;
      border: 1px solid #38f ;
    }
    .page a.prev{
      width:50px;
    }
    .page span{
      width: 34px;
      height: 34px;
      border: 1px solid transparent;
      cursor: pointer;
      display:block;
      float: left;
      text-decoration: none;
      text-align:center;
      line-height: 34px;
      cursor: default;
    }
  /style>
/head>

body>
table class="tt" border="1" align="center" width="80%" cellpadding="10">
  tr>
    th>ID/th>
    th>姓名/th>
    th>年齡/th>
    th>專業(yè)/th>
  /tr>
  %
  DBUtil dbutil=new DBUtil();
  Connection conn=dbutil.getCon();
  //Connection conn = new DBUtil().getCon();
  PreparedStatement pstmt1 = conn.prepareStatement("select count(*) from student");
  ResultSet rs1 = pstmt1.executeQuery();
  rs1.next();
  int recordCount = rs1.getInt(1);   //記錄總數(shù)
  int pageSize = 10;          //每頁記錄數(shù)
  int start=1;            //顯示開始頁
  int end=10;              //顯示結(jié)束頁
  int pageCount = recordCount%pageSize==0 ? recordCount/pageSize : recordCount/pageSize+1; 
  int currPage = request.getParameter("p")==null ? 1 : Integer.parseInt(request.getParameter("p"));
  
  currPage = currPage1 ? 1 : currPage;
  currPage = currPage>pageCount ? pageCount : currPage;
  
  PreparedStatement pst = conn.prepareStatement("select * from student limit ?,?");
  pst.setInt(1,currPage*pageSize-pageSize);
  pst.setInt(2,pageSize);
  ResultSet rs = pst.executeQuery();
  
  while(rs.next()){
  %>
  tr align="center">
  td>%=rs.getInt(1) %>/td>
  td>%=rs.getString(2) %>/td>
  td>%=rs.getInt("age") %>/td>
  td>%=rs.getString(4) %>/td>
  /tr>
  %
  }
  %>
  tr>
     th colspan="4" class="page">
       % 
         out.print(String.format("a class=\"prev\" href=\"?p=%d\">首頁/a>",1));
         if(currPage>=7){
           start=currPage-5;
           end=currPage+4;
         }
         if(start>(pageCount-10)){
           start=pageCount-9;
         }
         if(currPage>1){
           out.print(String.format("a class=\"prev\" href=\"?p=%d\">上一頁/a>",currPage-1));
         }
         
         for(int i=start;i=end;i++){
           if(i>pageCount) break;
           String pageinfo=String.format("a href=\"?p=%d\">%d/a>",i,i);
           if(i==currPage){
             pageinfo=String.format("span>%d/span>",i);
           }
           out.print(pageinfo);
         }
         
         if(currPage=pageCount){
           out.print(String.format("a class=\"prev\" href=\"?p=%d\">下一頁/a>",currPage+1));
         }
         
         out.print(String.format("a class=\"prev\" href=\"?p=%d\">尾頁/a>",pageCount)); 
       %>
     /th>
   /tr>
/table>
/body>
/html>

以上這篇jsp頁面數(shù)據(jù)分頁模仿百度分頁效果(實例講解)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • nodejs個人博客開發(fā)第六步 數(shù)據(jù)分頁
  • JSP數(shù)據(jù)分頁導(dǎo)出下載顯示進(jìn)度條樣式
  • JS代碼實現(xiàn)table數(shù)據(jù)分頁效果
  • jsp+servlet+javabean實現(xiàn)數(shù)據(jù)分頁方法完整實例
  • 無JS,完全php面向過程數(shù)據(jù)分頁實現(xiàn)代碼
  • JSP數(shù)據(jù)庫操數(shù)據(jù)分頁顯示
  • jquery+json實現(xiàn)數(shù)據(jù)列表分頁示例代碼
  • js前臺分頁顯示后端JAVA數(shù)據(jù)響應(yīng)
  • JS實現(xiàn)table表格數(shù)據(jù)排序功能(可支持動態(tài)數(shù)據(jù)+分頁效果)
  • js對象實現(xiàn)數(shù)據(jù)分頁效果

標(biāo)簽:廣州 南京 大連 樂山 黃石 銅川 內(nèi)江 貸款邀約

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《jsp頁面數(shù)據(jù)分頁模仿百度分頁效果(實例講解)》,本文關(guān)鍵詞  jsp,頁面,數(shù)據(jù),分頁,模仿,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《jsp頁面數(shù)據(jù)分頁模仿百度分頁效果(實例講解)》相關(guān)的同類信息!
  • 本頁收集關(guān)于jsp頁面數(shù)據(jù)分頁模仿百度分頁效果(實例講解)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    阆中市| 施秉县| 大方县| 吉隆县| 开远市| 张北县| 中西区| 锡林浩特市| 专栏| 丰都县| 松阳县| 司法| 永嘉县| 龙里县| 辛集市| 宁海县| 舞钢市| 酒泉市| 涞水县| 克山县| 乌兰察布市| 衡东县| 新乡县| 思茅市| 班戈县| 元江| 德昌县| 新田县| 诸城市| 焉耆| 邵东县| 无极县| 改则县| 株洲县| 翼城县| 西乌| 霍邱县| 翁源县| 泽普县| 奉贤区| 桃源县|