简单的jsp分页判断

<c:choose>
<c:when test="${maxPage == 0}">
<div align="center"><h3><font color="red">没有数据!!!!!</font></h3></div>
</c:when>
<c:otherwise>
<table width="100%" bgcolor="whitesmoke" border="0" align="center" cellpadding="2" cellspacing="2" class="list_bt">
<tr>

<td align="center">
总共【<font color="red">${maxPage}</font>】页   <font color="red">${page}</font>/<font color="red">${maxPage}</font>  
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=1&username=<%=user.getRealName() %>">首页</a>
 
<c:choose>
<c:when test="${page == 1}">上一页</c:when>
<c:otherwise>
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=${page-1}&username=<%=user.getRealName() %>">上一页</a>
</c:otherwise>
</c:choose>
 
<c:choose>
<c:when test="${page == 1 || page == 2 || page == 3 || page == 4}">
<c:if test="${maxPage <= 4}">
<c:forEach begin="1" end="${maxPage}" var="i">
<c:if test="${page == i}">
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=${i }&username=<%=user.getRealName() %>"><font color="red">${i}</font></a>
</c:if>
<c:if test="${page != i}">
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=${i }&username=<%=user.getRealName() %>"><font color="blue">${i}</font></a>
</c:if>
</c:forEach>
</c:if>
<c:if test="${maxPage > 4}">
<c:forEach begin="1" end="5" var="i">
<c:if test="${page == i}">
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=${i }&username=<%=user.getRealName() %>"><font color="red">${i}</font></a>
</c:if>
<c:if test="${page != i}">
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=${i }&username=<%=user.getRealName() %>"><font color="blue">${i}</font></a>
</c:if>
</c:forEach>
</c:if>
</c:when>
<c:when test="${page+2 < maxPage}">
<c:forEach begin="${page-2}" end="${page+2}" var="i">
<c:if test="${page == i}">
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=${i }&username=<%=user.getRealName() %>"><font color="red">${i}</font></a>
</c:if>
<c:if test="${page != i}">
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=${i }&username=<%=user.getRealName() %>"><font color="blue">${i}</font></a>
</c:if>
</c:forEach>
</c:when>
<c:otherwise>
<c:forEach begin="${maxPage-4}" end="${maxPage}" var="i">
<c:if test="${page == i}">
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=${i }&username=<%=user.getRealName() %>"><font color="red">${i}</font></a>
</c:if>
<c:if test="${page != i}">
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=${i }&username=<%=user.getRealName() %>"><font color="blue">${i}</font></a>
</c:if>
</c:forEach>
</c:otherwise>
</c:choose>
 
<c:choose>
<c:when test="${page == maxPage}">下一页</c:when>
<c:otherwise>
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=${page+1}&username=<%=user.getRealName() %>">下一页</a>
</c:otherwise>
</c:choose>
 
<a href="<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&page=${maxPage}&username=<%=user.getRealName() %>">尾页</a>
   
<input type="text" id="pageId" value="${page }" style="width: 30px" /> 
<input type="button" value="跳转" onclick="mySkip()" />
<input type="hidden" value="${maxPage }" id="maxId" />
</td>

</tr>
</table>
</c:otherwise>
</c:choose>

function mySkip(){
//var page = document.getElementById("pageId").value ;
var page = parseInt($("#pageId").val()) ;
var maxPage = $("#maxId").val() ;
var re = new RegExp("[0-9]") ;
alert(page) ;
alert(re.test(page)) ;
if(page > 0 && page <= maxPage){
location = "<%=basePath %>ApplyServlet?b=findAllFund&digit=3&param=30&username=<%=user.getRealName() %>&page="+page ;
}else{
alert("无效页数!!!") ;
}
}


取整数问题
1.丢弃小数部分,保留整数部分
parseInt(5/2)
2.向上取整,有小数就整数部分加1
Math.ceil(5/2)
3,四舍五入.
Math.round(5/2)
4,向下取整
Math.floor(5/2)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值