JavaEE pager-taglib 分页插件(2)

/** 
 * Project Name:TestPage 
 * File Name:PageModel.java 
 * Package Name:com.servlet 
 * Date:2013年8月12日 下午3:17:41 
 * Copyright (c) 2013, [email protected] All Rights Reserved. 
 * 
*/  
  
package com.servlet;  

import java.util.List;

/** 
 * ClassName:PageModel <br/> 
 * Function: TODO ADD FUNCTION. <br/> 
 * Reason:   TODO ADD REASON. <br/> 
 * Date:     2013年8月12日 下午3:17:41 <br/> 
 * @author   zhangzhaoyu 
 * @version   
 * @since    JDK 1.6 
 * @see       
 */
public class PageModel {
	
	private int total;
	private List<User> datas;
	
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public List<User> getDatas() {
		return datas;
	}
	public void setDatas(List<User> datas) {
		this.datas = datas;
	}
	
}
 


<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<!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>Insert title here</title>
</head>
<body>
<pg:pager url="TestPage" items="${pm.total }" index="center" maxPageItems="5" maxIndexPages="10"
	isOffset="${true }" export="pageOffset,currentPageNumber=pageNumber" scope="request">
	<pg:param name="pageSize" value="5"/>
	
	<table border="1px">
		<tr>
			<td>username</td>
			<td>email</td>
			<td>telephone</td>
			<td>QQ</td>
		</tr>
		
		<c:forEach items="${pm.datas }" var="user" varStatus="listStatus">
			<pg:item>
				<tr>
					<td>${user.userName }</td>
					<td>${user.email }</td>
					<td>${user.telephone }</td>
					<td>${user.qq }</td>
				</tr>
			</pg:item>
			
		</c:forEach>
	</table>
	
	<pg:index>
		<pg:first><a href="${pageUrl}&pageNum=${pageNumber}">首页</a></pg:first>
		<pg:prev><a href="${pageUrl }&pageNum=${pageNumber}">前一页</a></pg:prev>
		<pg:pages>
			 <c:choose>
                <c:when test="${pageNumber eq currentPageNumber}">
                    <span style="color:red;">[${pageNumber}]</span>
                </c:when>
                <c:otherwise>
                    <a href="${pageUrl}&pageNum=${pageNumber}">${pageNumber }</a>
                </c:otherwise>
            </c:choose>
		</pg:pages>
		<pg:next >
			<a href="${pageUrl }&pageNum=${pageNumber}">下一页</a>
		</pg:next>
		<pg:last>
			<a href="${pageUrl }&pageNum=${pageNumber}">尾页</a>
		</pg:last>
		&nbsp;共: ${pm.total}
	</pg:index>
</pg:pager>
</body>
</html>

你可能感兴趣的:(javaee)