正在阅读:解决MVC下分页显示的问题解决MVC下分页显示的问题

2005-07-12 10:07 出处: 作者:ponky 责任编辑:moningfeng

  好了,到现在我们开始来真正看一下jsp中的处理,我们写一个computer.jsp,代码如下:

<%@ page import="com.util.BaseView,

com.attribute.Constants,

com.util.Page"%>

<%@ page contentType="text/html;charset=GB2312" language="java"
errorPage=""%>

<%@ taglib uri="/WEB-INF/swsoft-struts.tld"prefix="swtag"%>

<html>

<head>

<title></title>
</head>

<body bgcolor="#e3edfc">

<div id="Layer1" style="position:absolute; left:1px; top:2px;
width:780px; height:406px; z-index:1; background-color: #e3edfc; layer-background-color:
#e3edfc; border: 1px none #000000;">

<table width="100%" cellpadding="1">

<tr>

<td colspan="6">

<table width="100%" cellpadding="1">

<tr>

<td width="20%" align="center">BOOKNAME</td>

<td width="10%" align="center">AUTHOR</td>

<td width="10%" align="center">TYPE</td>

<td width="30%" align="center">PUBLISH</td>

<td width="10%" align="center">PRINCE</td>

<td colspan="2" align="center">SELECT</td>

</tr>

<%

String contextPath = request.getContextPath();

String url=contextPath+"/computer.do";

BaseView view=(BaseView)request.getAttribute(Constants.QUERY_RESULT);

Page setpage=(Page)request.getAttribute("page");

int currentPage=setpage.getCurrentPageNo();

System.out.println("this is currentPage="+currentPage);

int totalPut=setpage.getTotalSize();

System.out.println("this is totalPut="+totalPut);

int maxPerPage=setpage.getPageSize();

System.out.println("this is maxPerPage="+maxPerPage);

if(view.haveRecord()){

String sBgcolor="";

int length=view.getRecordCount();

for(int i=0;i<length;i++){

String type =view.getValue(i,2);

if(type.equals("1")){

type="computer";

}

if(i%2!=0){

sBgcolor="#A5C6EB";

}

else{

sBgcolor="#B7D7EF";

}

%>

<tr bgcolor=<%=sBgcolor%> height="10">

<td align="center" ><%=view.getValue(i,1)%></td>

<td align="center"><%=view.getValue(i,4)%></td>

<td align="center"><%=type%></td>

<td align="center"><%=view.getValue(i,5)%></td>

<td align="center"><%=view.getValue(i,8)%></td>

<td width="20%" align="center">BUY PARTICULAR</td>
</tr>

<%}}%>

</table>

</td>

</tr>
<tr>

<swtag:paginator url="<%=url%>"

currentPage="<%=currentPage%>"

totalPut="<%=totalPut%>"

maxPerPage="<%=maxPerPage%>"

showTotal="true"

showAllPages="true"

strUnit="页" />

</tr>

</table>

</div>
</body>

</html>

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品