[java]代码库
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>pager-taglib DEMO</title>
<script type="text/javascript" src="js/pager-taglib.js"></script>
</head>
<body>
<hr/>
<h1>DEMO 1</h1>
<h2>有form标签的get提交,有form标签可以提供搜索条件</h2>
<h2><jsp:param name="params" value="name1:value1"/>:为分页组件提供而外参数,在无form标签时非常有用</h2>
<form action="servlet/PageServlet" method="get">
a_name:<input name="a_name" value="${a_name }" type="text" title="搜索条件1"><br/>
b_name:<input name="b_name" value="${b_name }" type="text" title="搜索条件2">
<input type="submit" value="搜索"><br/><br/>
<table class="data" border="1" cellpadding="5" cellspacing="0">
<tr>
<td height="39">名字</td>
<td height="39">数值</td>
</tr>
<c:forEach items="${pageModel.list }" var="data">
<tr>
<td height="39">${data.name }</td>
<td height="39">${data.value }</td>
</tr>
</c:forEach>
</table>
<br/>
<jsp:include page="pager.jsp" flush="true">
<jsp:param name="url" value="servlet/PageServlet"/>
<jsp:param name="items" value="${pageModel.totalCount }"/>
<jsp:param name="params" value="name1:value1"/>
<jsp:param name="params" value="name2:value2"/>
</jsp:include>
</form>
<br/><br/><hr/>
<h1>DEMO 2</h1>
<h2>有form标签的post提交,有form标签可以提供搜索条件</h2>
<h2><jsp:param name="params" value="name1:value1"/>:为分页组件提供而外参数,在无form标签时非常有用</h2>
<form action="servlet/PageServlet" method="post">
a_name:<input name="a_name" value="${a_name }" type="text" title="搜索条件1"><br/>
b_name:<input name="b_name" value="${b_name }" type="text" title="搜索条件2">
<input type="submit" value="搜索"><br/><br/>
<table class="data" border="1" cellpadding="5" cellspacing="0">
<tr>
<td height="39">名字</td>
<td height="39">数值</td>
</tr>
<c:forEach items="${pageModel.list }" var="data">
<tr>
<td height="39">${data.name }</td>
<td height="39">${data.value }</td>
</tr>
</c:forEach>
</table><br/>
<jsp:include page="pager.jsp" flush="true">
<jsp:param name="url" value="servlet/PageServlet"/>
<jsp:param name="items" value="${pageModel.totalCount }"/>
<jsp:param name="params" value="name1:value1"/>
<jsp:param name="params" value="name2:value2"/>
</jsp:include>
</form>
<br/><br/><hr/>
<h1>DEMO 3</h1>
<h2>无form标签的提交,即用a标签跳转</h2>
<h2><jsp:param name="params" value="name1:value1"/>:为分页组件提供而外参数,在无form标签时非常有用</h2>
<table class="data" border="1" cellpadding="5" cellspacing="0">
<tr>
<td height="39">名字</td>
<td height="39">数值</td>
</tr>
<c:forEach items="${pageModel.list }" var="data">
<tr>
<td height="39">${data.name }</td>
<td height="39">${data.value }</td>
</tr>
</c:forEach>
</table><br/>
<jsp:include page="pager.jsp" flush="true">
<jsp:param name="url" value="servlet/PageServlet"/>
<jsp:param name="items" value="${pageModel.totalCount }"/>
<jsp:param name="params" value="name1:value1"/>
<jsp:param name="params" value="name2:value2"/>
</jsp:include>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
</body>
</html>
//源代码片段来自云代码http://yuncode.net