<%@ tag body-content="scriptless" display-name="pagging" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ attribute name="path" required="true" description="请求的路径"%>
<%@ attribute name="count" required="true" description="总页数"%>
<%@ attribute name="page" required="true" description="当前页数"%>
<%@ attribute name="size" required="true" description="每页显示条数"%>
<%@ attribute name="borderColor" description="边框颜色"%>
<%@ attribute name="backColor" description="背景颜色"%>
<%@ attribute name="selectColor" description="选中的背景颜色" %>
<script type="text/javascript">
function getCheck(path)
{
if(path.indexOf('?')==-1)
return path+"?";
else
return path+"&";
}
function buttonClick(theButton)
{
location.href=getCheck("${path}")+"page="+theButton.value+"&size="+${size};
}
function goClick()
{
var theValue = document.getElementById("textNum").value;
if(parseInt(theValue)<1||parseInt(theValue)>${count})
{
alert("您输入的页数超出总页数!");
}else{
location.href=path+"page="+theValue;
}
}
function goClick2(isBack)
{
if(isBack)
{
if(${page}>1)
{
location.href=getCheck("${path}")+"page="+(${page}-1)+"&size="+${size};
}else
{
document.getElementById("btnUp").disabled="disabled";
}
}else
{
if(${page}<${count})
{
location.href=getCheck("${path}")+"page="+(${page}+1)+"&size="+${size};;
}else
{
document.getElementById("btnNext").disabled="disabled";
}
}
}
</script>
<!------------------------------------------>
<c:set var="startSize" value="1" />
<c:set var="endSize" value="10"/>
<c:if test="${count<=10}">
<c:set var="endSize" value="${count}"/>
</c:if>
<c:if test="${count>10}">
<c:if test="${page-4>0&&page+5<=count}">
<c:set var="startSize" value="${page-4}" />
<c:set var="endSize" value="${page+5}"/>
</c:if>
<c:if test="${page+5>count}">
<c:set var="startSize" value="${count-9}" />
<c:set var="endSize" value="${count}"/>
</c:if>
</c:if>
<!------------------------------------------>
<table border="0" cellpadding="0" cellspacing="0" class="fun">
<tr>
<td><input id="btnUp" type="button" width="80px" value="上一页" class="buttom" οnclick="goClick2(true)"/><td>
<c:forEach var="curNum" begin="${startSize}" end="${endSize}" step="1">
<c:if test="${page==curNum}">
<td><input type="button" value="${curNum}" class="buttomSelect"/><td>
</c:if>
<c:if test="${page!=curNum}">
<td><input type="button" value="${curNum}" class="buttom" οnclick="buttonClick(this)"/><td>
</c:if>
</c:forEach>
<td><input id="btnNext" type="button" width="80px" value="下一页" class="buttom" οnclick="goClick2(false)"/><td>
<td>
<select id="textNum" class="textborder" οnchange="buttonClick(this)">
<c:forEach var="indexValue" begin="1" end="${count}" step="1">
<c:if test="${indexValue==page}">
<option value="${indexValue}" selected>第${indexValue}页</option>
</c:if>
<c:if test="${indexValue!=page}">
<option value="${indexValue}">第${indexValue}页</option>
</c:if>
</c:forEach>
</select>
<td>
</tr>
</table>
jsp paging
最新推荐文章于 2022-06-30 14:29:28 发布