ssm框架整合的分頁功能

&&&&&&此博文參考於:http://blog.csdn.net/peng_hong_fu/article/details/53645924  
css

並只運行了該大神的分頁邏輯功能。先剔出以下:html

************************ssm框架的jar包以及配置文件,在這裏就不貼了,直接上代碼.java


-----分頁的實體工具類:page.javasql

package com.topsun.util;

import java.util.List;

//分頁
public class Page<T> {
    private int currPage;//當前頁
    private int pageSize;//每頁顯示的記錄數
    private int totalCount;//總記錄數
    private int totalPage;//總頁數
    private List<T> lists;//每頁顯示的數據
    public Page(int currPage, int pageSize, int totalCount, int totalPage, List<T> lists) {
        super();
        this.currPage = currPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.totalPage = totalPage;
        this.lists = lists;
    }
    public Page() {
        super();
    }
    public int getCurrPage() {
        return currPage;
    }
    public void setCurrPage(int currPage) {
        this.currPage = currPage;
    }
    public int getPageSize() {
        return pageSize;
    }
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    public int getTotalCount() {
        return totalCount;
    }
    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }
    public int getTotalPage() {
        return totalPage;
    }
    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }
    public List<T> getLists() {
        return lists;
    }
    public void setLists(List<T> lists) {
        this.lists = lists;
    }
}

---------------------------------------------------------------------------------------------------------app

-----controller 層的分頁:框架

wKioL1nYn6HA8I1AAABkmy3gcQw180.png-wh_50


--------service 層 方法:jsp

wKioL1nYn9ehcs1jAAAcjZlu6Jk937.png-wh_50


--------serviceImpl層 實現類:ide

wKioL1nYoF7grOsNAAAaCoMTWc0461.png-wh_50

wKiom1nYoKzzJYMtAADD7vGrDzo619.png-wh_50


--------dao層方法截圖:工具

wKioL1nYoPCCoAg3AAAaQlwgf3E976.png-wh_50

-------mapper.xml文件裏的sql語句:ui

wKioL1nYoSGQacn6AABhZqF8E-E543.png-wh_50


------list.jsp頁面:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@page isELIgnored="false" %><%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>主頁</title><style type="text/css">    td{text-align: center;}    .td2{text-align: right;}    .table1{            border:1px solid #ddd;            width:900px;                    }        thead{            background-color:lightblue;        }</style></head><body>        <c:if test="${!empty requestScope.cjw}">        <table border="1" cellpadding="10" cellspacing="0" class="table1">        <thead>            <tr>                <td>編號</td>                <td>用戶名</td>                <td>年齡</td>                <td>Edit</td>                <td>Delete</td>            </tr>            </thead>            <c:forEach items="${requestScope.cjw.lists}" var="u">                <tr>                    <th>${u.id}</th>                    <th>${u.name}</th>                    <th>${u.age}</th>                    <th><a href="edit?id=${u.id}">Edit</a></th>                    <th><a href="delete?id=${u.id}" confirm('肯定要刪除嗎')">Delete</a></th>                </tr>            </c:forEach>                </table>        </c:if><table  border="0" cellspacing="0" cellpadding="0"  width="900px"><tr><td class="td2">   <span>第${requestScope.cjw.currPage}/ ${requestScope.cjw.totalPage}頁</span>&nbsp;&nbsp;   <span>總記錄數:${requestScope.cjw.totalCount}&nbsp;&nbsp;每頁顯示:${requestScope.cjw.pageSize}</span>&nbsp;&nbsp;   <span>       <c:if test="${requestScope.pagemsg.currPage != 1}">             <a href="${pageContext.request.contextPath}/selectPage?currentPage=1">[首頁]</a>&nbsp;&nbsp;            <a href="${pageContext.request.contextPath}/selectPage?currentPage=${requestScope.cjw.currPage-1}">[上一頁]</a>&nbsp;&nbsp;             </c:if>       <c:if test="${requestScope.cjw.currPage != requestScope.cjw.totalPage}">           <a href="${pageContext.request.contextPath}/selectPage?currentPage=${requestScope.cjw.currPage+1}">[下一頁]</a>&nbsp;&nbsp;           <a href="${pageContext.request.contextPath}/selectPage?currentPage=${requestScope.cjw.totalPage}">[尾頁]</a>&nbsp;&nbsp;       </c:if>   </span></td></tr></table></body></html>

相關文章
相關標籤/搜索