<?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE mapper 3 PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" 4 "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"> 5 <mapper namespace="ec.help.dao.UserDao"> 6 7 <resultMap type="ec.help.bean.User" id="userResult" > 8 <id column="id" javaType="string" /> 9 <result column="username" javaType="string" /> 10 <result column="password" javaType="string" /> 11 </resultMap> 12 13 <sql id="userColumn"> id, username, password</sql> 14 15 19 <select id="getAllUser" parameterType="map" resultType="ec.help.bean.User" > 20 select * from User 21 </select> 22 23 <!-- 分页使用SQL --> 24 <select id="getUserByPage" resultType="ec.help.bean.User" > 25 select * from user limit #{0},#{1} 26 </select> 27 </mapper>
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div class="pagging">
<div class="left">共${userNum}条记录</div>
<div class="right">
<c:if test="${currentPage == 1}">
<span class="disabled"><< 前一页</span>
</c:if>
<c:if test="${currentPage != 1}">
<a href="listUser.do?page=${currentPage-1}"><< 前一页</a>
</c:if>
<c:if test="${currentPage == 1}">
<span class="current">1</span>
</c:if>
<c:if test="${currentPage != 1}">
<a href="listUser.do?page=1">1</a>
</c:if>
<%
int pageTimes = (Integer)session.getAttribute("pageTimes");
for(int i=1;i<pageTimes;i++)
{
request.setAttribute("page", i+1);
%>
<c:if test="${currentPage == page}">
<span class="current"><%=i+1%></span>
</c:if>
<c:if test="${currentPage != page}">
<a href="listUser.do?page=<%=i+1%>"><%=i+1%></a>
</c:if>
<%} %>
<c:if test="${currentPage == pageTimes}">
<span class="disabled">后一页 >></span>
</c:if>
<c:if test="${currentPage != pageTimes}">
<a href="listUser.do?page=${currentPage+1}">后一页 >></a>
</c:if>
</div>
</div>
原文网址:https://www.cnblogs.com/xianan87/p/3948816.html