Java中实现分页效果的详细代码
2个回答
2013-07-30
展开全部
<head>
<%
const MaxPerPage=20
dim sql
dim rs
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
%>
</head>
<body>
<%
conn = "DBQ=" + server.mappath("wj028.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
sql = "SELECT * FROM USER order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open SQL,conn,1,1
rs.MoveFirst
rs.pagesize=MaxPerPage
howmanyfields=rs.Fields.Count-1
If trim(Request("Page"))<>"" then
CurrentPage= CLng(request("Page"))
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If
if rs.eof then
response.write "<p align='center'>没有记录!</p>"
else
totalPut=rs.recordcount
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage<totalPut then
rs.move(currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
end if
end if
dim n,k
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if%>
<% i=0
do while not rs.EOF and i<maxperpage
%>
<%
rs.movenext
i=i+1
loop
%>
第<%=currentpage%>页
共<%=n%>页
<%
k=currentpage
if k<>1 then
response.write "[<b>"+"<a href='list.asp?page=1'>首页</a></b>]"
response.write "[<b>"+"<a href='list.asp?page="+cstr(k-1)+"'>上一页</a></b>]"
else
Response.Write "[首页][上一页]"
end if
if k<>n then
response.write "[<b>"+"<a href='list.asp?page="+cstr(k+1)+"'>下一页</a></b>] "
response.write "[<b>"+"<a href='list.asp?page="+cstr(n)+"'>尾页</a></b>] "
else
Response.Write "[下一页][尾页]"
end if
%>
<%
end if
set rs=nothing
set conn=nothing
%>
</body>
<%
const MaxPerPage=20
dim sql
dim rs
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
%>
</head>
<body>
<%
conn = "DBQ=" + server.mappath("wj028.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
sql = "SELECT * FROM USER order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open SQL,conn,1,1
rs.MoveFirst
rs.pagesize=MaxPerPage
howmanyfields=rs.Fields.Count-1
If trim(Request("Page"))<>"" then
CurrentPage= CLng(request("Page"))
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If
if rs.eof then
response.write "<p align='center'>没有记录!</p>"
else
totalPut=rs.recordcount
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage<totalPut then
rs.move(currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
end if
end if
dim n,k
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if%>
<% i=0
do while not rs.EOF and i<maxperpage
%>
<%
rs.movenext
i=i+1
loop
%>
第<%=currentpage%>页
共<%=n%>页
<%
k=currentpage
if k<>1 then
response.write "[<b>"+"<a href='list.asp?page=1'>首页</a></b>]"
response.write "[<b>"+"<a href='list.asp?page="+cstr(k-1)+"'>上一页</a></b>]"
else
Response.Write "[首页][上一页]"
end if
if k<>n then
response.write "[<b>"+"<a href='list.asp?page="+cstr(k+1)+"'>下一页</a></b>] "
response.write "[<b>"+"<a href='list.asp?page="+cstr(n)+"'>尾页</a></b>] "
else
Response.Write "[下一页][尾页]"
end if
%>
<%
end if
set rs=nothing
set conn=nothing
%>
</body>
2013-07-30
展开全部
分页显示有几中 一种是把数据保存到session里面 然后分页显示
还有就是每次都从数据库获得一次
等等还有很多方法的 分页显示没有固定模式 方法多多
还有就是每次都从数据库获得一次
等等还有很多方法的 分页显示没有固定模式 方法多多
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询