您的位置:首页 > Web前端

Jsp前端公共分页实现!!!

2015-12-14 16:08 447 查看
page.js

$(function(){
$("#firstPage").click(
function(){
$("input[name='hidden']").val(1);
queryByPage();
}
);

$("#lastPage").click(
function(){
$("input[name='hidden']").val($("#totalPage").text());
queryByPage();
}
);

$("#previousPage").click(
function(){
var currentPage = $("input[name='hidden']").val();
if(currentPage>1){
currentPage--;
$("input[name='hidden']").val(currentPage);
queryByPage();
}
}
);

$("#nextPage").click(
function(){
var currentPage = $("input[name='hidden']").val();
if(currentPage<$("#totalPage").text()){
currentPage++;
$("input[name='hidden']").val(currentPage);
queryByPage();
}
}
);
})


results.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<script type="text/javascript" src="scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="scripts/page.js"></script>
<script type="text/javascript">
function queryByPage(){
var currentPage = $("input[name='hidden']").val();
$("#rightFdr").load("mediafirst/projectList.htm",{
"method" : "show",
"starttime" : "${starttime}",
"endtime" : "${endtime}",
"lowprice" : "${lowprice}",
"highprice" : "${highprice}",	//这四个都是参数
"currentPage":currentPage	//当前页数
});
}
</script>
</head>

<body>
<div id="rightFdr">
<div class="topbox">
<div>
<ul>
<td colspan="4" class="fenye">
共<span id="totalPage">${page.pageCount}</span>页  当前第
<span id="currentPage">${page.currentPage}/${page.pageCount}</span>页  
<a href="javascript:void(0);" id="firstPage">首页</a>  
<a href="javascript:void(0);" id="previousPage">上一页</a>  
<a href="javascript:void(0);" id="nextPage">下一页</a>  
<a href="javascript:void(0);" id="lastPage">末页</a></td>
</ul>
</div>
</div>
</div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: