当前位置:首页 » 软件设计 » 分页设计

分页设计

发布时间: 2021-01-15 17:42:28

① 网页设计中如何实现分页的效果

用GridView空间,里面有自带的分页功能,将属性设置为true,然后在相应的事件里面写数据库的查询代码就可以了!
一、动态网页:这里有一段PHP代码,供参考,我这边运行成功:

1.显示内容部分
<?php
$page=$_GET["page"];
if($page=="")
{$page=1;}
if(is_numeric($page))
{
$page_size=30;
$query="select count(*) as total from solution order by id desc";
$result = mysql_db_query($dbn, $query);
$message_count=mysql_result($result,0,"total");
$page_count=ceil($message_count/$page_size);
$offset=($page-1)*$page_size;
$sql=mysql_db_query($dbn,"select * from solution order by id desc limit $offset,$page_size");
$row=mysql_fetch_object($sql);
if(!$row)
{
echo("No data!");
}
?>
<?php
do
{
?>
</p>
<p>+ <a href="<?php echo $row->pageurl; ?>.html" title="<?php echo $row->pagetitle; ?>"><?php echo $row->pagetitle; ?></a></p>
<?php
}while($row=mysql_fetch_object($sql));
?>
<?php
}
?>

2.分页部分
<?php
if($page!=1)
{
echo "<a href=index.php?page=1>First</a> ";
echo "<a href=index.php?page=".($page-1).">Previous</a> ";
}
if($page<$page_count)
{
echo "<a href=index.php?page=".($page+1).">Next</a> ";
echo "<a href=index.php?page=".$page_count.">End</a>";
}
?>
</span> <span> Current Page:<?php echo $page;?> / <?php echo $page_count;?></span>
<?php
mysql_free_result($sql);
?>

二、静态网页用js:
用JavaScript伪分页,实际上内容还是在同一个页面上。

<div id="page_1">第1页内容</div>
<div id="page_2">第2页内容</div>
<div id="page_3">第3页内容</div>
<div id="page_4">第4页内容</div>
<script type="text/javascript">//<![CDATA[
var curpage=document.hash.substr(1);
for (var i=1;i<=4;++i) {
document.getElementById('page_'+i).style.display=(i==curpage)?'':'none';
}
//]]></script>

然后用 page.htm#1 page.htm#2 page.htm#3 page.htm#4 来链接4页。

② 在问卷星中设计问卷的时候,分页栏是怎么用的

可以查看帮助:分页栏使用

③ JPress 中如何设计分页显示的条目

if Rs.RecordCount>0 then page=clng(request("page")) rszs=rs.recordcount Rs.PageSize=15 if page=0 then page=1 pages=Rs.pagecount if page > pages then page=pages Rs.AbsolutePage=page For i=1 to Rs.PageSize 循环数据 rs.movenext

④ java前段分页怎么设计

ListAction.java
packagecom.sy.action;
importjava.util.List;
importcom.opensymphony.xwork2.ActionSupport;
importcom.sy..AdminDao;
importcom.sy..NewsDao;
importcom.sy..impl.AdminDaoImpl;
importcom.sy..impl.NewsDaoImpl;
importcom.sy.vo.Admin;
importcom.sy.vo.News;
{
=1L;
inti=1;//中间变量
privateintk;//储存最大页面数
privateintpageNow=1;//页码数,初始为
privateintpageSize=5;//页面行数
privateintintRowCount;//总行数
privateintintPageCount;//总页数
privateAdminadmin;
privateList<Admin>Adminss;
privateNewsnews;
@SuppressWarnings("unchecked")
privateList<News>Newss;
privateintid;
privateintaid;
publicNewsgetNews(){
returnnews;
}
publicvoidsetNews(Newsnews){
this.news=news;
}
@SuppressWarnings("unchecked")
publicList<News>getNewss(){
returnNewss;
}
publicvoidsetNewss(List<News>newss){
Newss=newss;
}
publicintgetId(){
returnid;
}
publicvoidsetId(intid){
this.id=id;
}
publicAdmingetAdmin(){
returnadmin;
}
publicvoidsetAdmin(Adminadmin){
this.admin=admin;
}
publicList<Admin>getAdminss(){
returnAdminss;
}
publicvoidsetAdminss(List<Admin>adminss){
Adminss=adminss;
}
publicintgetAid(){
returnaid;
}
publicvoidsetAid(intaid){
this.aid=aid;
}
publicintgetPageNow(){
returnpageNow;
}
publicvoidsetPageNow(intpageNow){
this.pageNow=pageNow;
}
publicintgetPageSize(){
returnpageSize;
}
publicvoidsetPageSize(intpageSize){
this.pageSize=pageSize;
}
publicintgetIntRowCount(){
returnintRowCount;
}
publicvoidsetIntRowCount(intintRowCount){
this.intRowCount=intRowCount;
}
publicintgetIntPageCount(){
returnintPageCount;
}
publicvoidsetIntPageCount(intintPageCount){
this.intPageCount=intPageCount;
}
publicintgetK(){
returnk;
}
publicvoidsetK(intk){
this.k=k;
}
@SuppressWarnings("unchecked")
@Override
//显示新闻列表
publicStringexecute()throwsException{
NewsDaonpage=newNewsDaoImpl();
intRowCount=npage.count();
k=(intRowCount+pageSize-1)/pageSize;
intPageCount=(intRowCount+pageSize-1)/pageSize;//计算出总页数
if(pageNow<1){
pageNow=1;
}
if(pageNow>intPageCount)
pageNow=intPageCount;
i=(pageNow-1)*pageSize;
NewsDaonlist=newNewsDaoImpl();
if(null!=nlist.queryByPage(i,pageSize)){
Newss=nlist.queryByPage(i,pageSize);
returnSUCCESS;
}else{
return"failure";
}
}
..
}
listNews.jsp
<%@pagelanguage="java"pageEncoding="UTF-8"%>
<%@taglibprefix="s"uri="/struts-tags"%>
<%
Stringpath=request.getContextPath();
StringbasePath=request.getScheme()+"://"
+request.getServerName()+":"+request.getServerPort()
+path+"/";
%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
<html>
<head>
<basehref="<%=basePath%>">
<title>MyJSP'index.jsp'startingpage</title>
</head>
<body>
..
<center>
共<s:propertyvalue="intRowCount"/>记录&nbsp;&nbsp;
第<s:propertyvalue="pageNow"/>页&nbsp;&nbsp;
<s:urlid="url_pre"value="list.action">
<s:paramname="pageNow"value="pageNow-1"></s:param>
</s:url>
<s:urlid="url_next"value="list.action">
<s:paramname="pageNow"value="pageNow+1"></s:param>
</s:url>
<s:iteratorvalue="Newss"status="status">
<s:urlid="url"value="list.action">
<s:paramname="pageNow"value="pageNow"/>
</s:url>
</s:iterator>
<s:iftest="pageNow==1">
<s:ahref="%{url_pre}">最前一页</s:a>
</s:if>
<s:else>
<s:ahref="%{url_pre}">上一页</s:a>
</s:else>
<s:iftest="pageNow==k">
<s:ahref="%{url_next}">最后一页</s:a>
</s:if>
<s:else>
<s:ahref="%{url_next}">下一页</s:a>
</s:else>
</center>
</body>
</html>
NewsDao.java
packagecom.sy..impl;
importjava.sql.PreparedStatement;
importjava.sql.ResultSet;
importjava.text.SimpleDateFormat;
importjava.util.ArrayList;
importjava.util.List;
importcom.sy..NewsDao;
importcom.sy.util.DataBaseConnection;
importcom.sy.util.StringUtil;
importcom.sy.vo.News;
{
//获取分页新闻列表
@SuppressWarnings("unchecked")
publicList<News>queryByPage(inti,intpageSize){
List<News>newss=newArrayList();
PreparedStatementpstmt=null;
Stringsql=null;
ResultSetrs=null;
DataBaseConnectiondbc=null;
dbc=newDataBaseConnection();
sql="select*"+i+","+pageSize;
try
{
pstmt=dbc.getConnection().prepareStatement(sql);
rs=pstmt.executeQuery();
while(rs.next())
{
Newsnews=newNews();
news.setId(rs.getInt("id"));
news.setName(rs.getString("name"));
news.setTitle(rs.getString("title"));
news.setDate(rs.getString("date"));
news.setEmail(rs.getString("email"));
news.setContent(rs.getString("content"));
i++;
newss.add(news);
}
rs.close();
pstmt.close();
}
catch(Exceptione)
{
System.out.println(e);
}
finally
{
dbc.close();
}
returnnewss;
}
//查询总行数
publicintcount(){
intintRowCount=0;//总行数
PreparedStatementpstmt=null;
Stringsql=null;
ResultSetrs=null;
DataBaseConnectiondbc=null;
dbc=newDataBaseConnection();
sql="selectcount(id)fromstruts2neworderbyidasc";
try
{
pstmt=dbc.getConnection().prepareStatement(sql);
rs=pstmt.executeQuery();
rs.next();//游标指向第一行
intRowCount=rs.getInt(1);//取得总行数
rs.close();
pstmt.close();
}
catch(Exceptione)
{
System.out.println(e);
}
finally
{
dbc.close();
}
returnintRowCount;
}
}

⑤ asp.net 网页分页设计

有两种方法:
1、GridView控件自抄带的分页功能,方便快捷,不过缺点很明显,性能差。
2、自己写,自己写的话就需要SQl方面的知识了,最好写个存储过程,在存储过程中设两个参数,一个是存储页的大小,一个存储当前页码。这样每次给它不同的值就能实现分页查询数据了。

⑥ PCB设计如何使用分页连接符

页码不用填写,是自动产生的。如果你不要显示页码,可在Options(选项)--专Preferences(参数)的属Milcellaneous(杂项)选项卡中,把Global Visibility前的方框复选勾去掉。

⑦ java分页设计,急!

一个BBS数据库,你将相关数据库查询语句改改,应该就行了(文件名ShowArticleFlat.jsp)
<%@ page language="java" contentType="text/html; charset=gbk"
pageEncoding="gbk"%>

<%@page import="java.sql.*" %>

<%
int pageSize = 3;//每一页显示信息的条数
String strPageNo = request.getParameter("pageNo");//接收传入的页码
int pageNo; //当前的页码
if(strPageNo == null || strPageNo.equals("")) {
pageNo = 1;
} else {
try {
pageNo = Integer.parseInt(strPageNo.trim());
} catch(NumberFormatException e) {
pageNo = 1;
}
if(pageNo <= 0) {
pageNo = 1;
}
}

Class.forName("com.mysql.jdbc.Driver");//获取数据库驱动
String url = "jdbc:mysql://localhost/bbs?user=root&password=root";
Connection conn = DriverManager.getConnection(url);//获取数据库连接

Statement stmtCount = conn.createStatement();
ResultSet rsCount = stmtCount.executeQuery("select count(*) from article where pid=0");
rsCount.next();
int totalRecords = rsCount.getInt(1);//获得数据库中的所有记录数
int totalPages = totalRecords % pageSize == 0 ? totalRecords / pageSize : totalRecords / pageSize + 1;//总共分多少页
if(pageNo > totalPages) { //如果接收的页码大于总页码,那么就将页码设置成最大页码
pageNo = totalPages;
}
int startPos = (pageNo - 1) * pageSize;

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from article where pid=0 order by pdate desc limit " + startPos + "," + pageSize);//获取数据库查询结果集
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>Insert title here</title>
</head>
<body>
<a href="Post.jsp">发表新帖</a>
<table border="1">
<%
while(rs.next()) {
%>
<tr>
<td><%=rs.getString("title") %></td>
</tr>
<%
}
rs.close();
stmt.close();
conn.close();
%>
</table>
共<%=totalPages %>页 第<%=pageNo %>页
<a href="ShowArticleFlat.jsp?pageNo=1">首页</a>
<a href="ShowArticleFlat.jsp?pageNo=<%=pageNo-1%>">上一页</a>
<a href="ShowArticleFlat.jsp?pageNo=<%=pageNo+1%>">下一页</a>
<a href="ShowArticleFlat.jsp?pageNo=<%=totalPages%>">尾页</a>
<form name="form1" action="ShowArticleFlat.jsp">
<select name="pageNo" onchange="document.form1.submit()">
<%
for(int i=1; i<=totalPages; i++) {
%>
<option value=<%=i%> <%=(pageNo == i) ? "selected" : ""%>>第<%=i%>页</option>
<%
}
%>
</select>
</form>

<form name="form2" action="ShowArticleFlat.jsp">
输入页码<input type="text" name="pageNo" value=<%=pageNo%>>
<input type="submit" value="GO">
</form>

</body>
</html>

⑧ 求解HTML分页JS的设计和实现

这个用HTML也可以做用JS也可以做,不过这个功能是用后台完成的。

⑨ 如何设计api分页

常规的分页方式
API处理分页看似简单,实际上暗藏危机。最常见的分页方式,大概是下面这样的
/users/?page=1&limit=5
//服务端返回
{
"code": 0,
"pagination": {
"page": 1,
"limit": 5,
"total": 10
}
"data": {}
}
最理想的情况下,客户端请求第一页的5条数据,服务端如常返回,比如下图:
拿Twitter的图用一下,假设我们的数据库有10条数据,按照5条一页,正好有2页。
在理想情况下,客户端拉取数据时不会出现任何异常。但,这仅仅是正常情况,如果此时刚好有2条新数据插入。
数据库记录变为13。原来第二页的数据是[5, 4, 3, 2, 1],现在变为[7, 6, 5, 4, 3],我们再一次拿到了第一页的数据。同理,如果用户在拉取数据时正好有数据被删除,一样会出现类似的问题。
根据item_id分页
要解决此类问题,就不能使用常规的分页方式。现在,我们换一个思路,客户端拉取数据时不再传page,改为item_id,我们就把它称为max_id
/users/?max_id=5&limit=5
此时服务端就知道我们上次拉取到了item_id为5的数据,继续在它后面拉取5条, 如下图:
数据可以正常取回,不会再出现上一页中的[6,7]。好了,让我们再一次假设,此时又有8条数据插入了数据库。再一次获取数据
可以看出,再一次出现问题,我们又拿到了上一页的[10,9]。所以,我们得告诉服务端,上一次拿到哪一条数据了。所以继续增加一个since_id字段。
恩,再一次取出了正确的数据。可能你觉得一切都正常了,但还是隐藏了一个致命的缺陷。
上面的数据能正常获取,是因为数据都是一个有序的集合,如果数据无序,且从数据库取出时需要按照某个字段排序,那么一切再次打回原点:所有的分页都乱了。
如何设计分页API
可以看出,两种分页方式都存在问题。所以这两种需求都是必要的,我们需要根据不同的业务场景使用不同的分页方式。
为了不造成客户端的麻烦,我们对api的分页做了一些更改。
{
"code": 0,
"pagination": {
"page": 1,
"next": {
"sinceId": 11,
"maxId": 11
//page: 1
},
"limit": 5,
"total": 10
},
"data": {}
}
我们由服务端来决定如何分页,前端需要做的,只是把next字段直接拼接到url中,这样就可以应付各种分页情况。

热点内容
美发店认证 发布:2021-03-16 21:43:38 浏览:443
物业纠纷原因 发布:2021-03-16 21:42:46 浏览:474
全国著名不孕不育医院 发布:2021-03-16 21:42:24 浏览:679
知名明星确诊 发布:2021-03-16 21:42:04 浏览:14
ipad大专有用吗 发布:2021-03-16 21:40:58 浏览:670
公务员协议班值得吗 发布:2021-03-16 21:40:00 浏览:21
知名书店品牌 发布:2021-03-16 21:39:09 浏览:949
q雷授权码在哪里买 发布:2021-03-16 21:38:44 浏览:852
图书天猫转让 发布:2021-03-16 21:38:26 浏览:707
宝宝水杯品牌 发布:2021-03-16 21:35:56 浏览:837