分页显示问题/!

04-09-03 xxbb1234021
<%@ page contentType="text/html; charset=GBK"%>

import="javax.naming.*,javax.sql.*,java.sql.*, java.util.*, javax.ejb.*, javax.rmi.PortableRemoteObject, register.*" %>

<%@ page errorPage="error.jsp" %>

<%@ include file="trans.jsp"%>

<html>

<head>

<title>

searchbookByCategory

</title>

</head>

<body bgcolor="ffffff">

<center>

<table width="770" cellspacing="0" cellpadding="0" align="center">

<tr>

<td align="center"><%@ include file="/title.jsp"%>

</td>

</tr>

<tr>

<td align="center"><%@ include file="/search2.jsp"%>

</td>

</tr>

</table>

<%

int MaxPage;//总页数

int maxRow;//总行数

int pageSize =3;//一页显示3行

int intPage;//第几页

String category = request.getParameter("pro");

String num = request.getParameter("Page");

if(num!=null){

intPage=Integer.parseInt(num);

}else{

intPage=1;

}

try

{

Context ctx = new InitialContext();

facadeHome fhome = (facadeHome)PortableRemoteObject.narrow(ctx.lookup("facade"), facadeHome.class);

facade f = fhome.create();

Collection c = f.getBooksByCategory(category);

maxRow = c.size();

if( maxRow % pageSize == 0 )

{

MaxPage = maxRow / pageSize;

}

else

{

MaxPage = maxRow / pageSize + 1;

}

Iterator it = c.iterator();

%><table width=70%><%

if( MaxPage > 0){ int a = 0;

while(a<pageSize){

Book temp = (Book)it.next();

String bookid = temp.getBookid();

%>

<tr><td rowspan="4"><img src=<%=temp.getPicture()%>></td>

<td>书名:<a href="viewbook.jsp?bookid=<%=temp.getBookid()%>"><%=trans(temp.getName())%></a></td></tr>

<tr><td>作者:<%=trans(temp.getAuthor())%></td><td>译者:<%=trans(temp.getTranslator())%></td></tr>

<tr><td>价格:<%=temp.getPrice()%></td><td>会员价格:<%=temp.getMemberprice()%></td></tr>

<tr><td>出版社:<%=trans(temp.getPublisher())%></td>

<% int i = temp.getStock();

if(i>0){%>

<td><a href="<%=request.getContextPath()%>/showcart.jsp?Addbook=<%=bookid%>">加入购物车</a></td></tr>

<%}else{%>

<td><a href="noughtbook.jsp">加入购物车</a>  <font color="red">缺货</font></td></tr>

<%} //end of if

a++;

}%>

</table>

</center>

</body>

第<%=intPage%>页 共<%=MaxPage%>页

<%if(intPage>1){%><a href="result.jsp?Page=<%=intPage-1%>">上一页</a><%}%>

<%if(intPage<MaxPage){%><a href="result.jsp?Page=<%=intPage+1%>">下一页</a><%}%>

<%}}catch(Exception e)

{e.printStackTrace();}

%>

</html>

为什么我点“下一页”后,屏幕上面什么也没有啊!

xxbb1234021
2004-09-03 10:40
代码如下:

<%@ page contentType="text/html; charset=GBK"%>
import="javax.naming.*,javax.sql.*,java.sql.*, java.util.*, javax.ejb.*, javax.rmi.PortableRemoteObject, register.*" %>
<%@ page errorPage="error.jsp" %>
<%@ include file="trans.jsp"%>
<html>
<head>
<title>
searchbookByCategory
</title>
</head>
<body bgcolor="ffffff">
<center>
<table width="770" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td align="center"><%@ include file="/title.jsp"%>
		</td>
	</tr>
	<tr>
		<td align="center"><%@ include file="/search2.jsp"%>
		</td>
	</tr>
</table>
<%
	 int MaxPage;//总页数
   	 int maxRow;//总行数
   	 int pageSize =3;//一页显示3行
   	 int intPage;//第几页

String category = request.getParameter("pro");
String num = request.getParameter("Page");
if(num!=null){
intPage=Integer.parseInt(num);
}else{
intPage=1;
}

try
{
Context ctx = new InitialContext();
facadeHome fhome = (facadeHome)PortableRemoteObject.narrow(ctx.lookup("facade"), facadeHome.class);
facade f = fhome.create();
Collection c = f.getBooksByCategory(category);
	maxRow = c.size();
         if( maxRow % pageSize == 0 )
      {
         MaxPage = maxRow / pageSize;
      }
      else
      {
         MaxPage = maxRow / pageSize + 1;
      }
Iterator it = c.iterator();
%><table width=70%><%
if( MaxPage > 0){  int a = 0;
while(a<pageSize){
	Book temp = (Book)it.next();
        String bookid = temp.getBookid();
%>

<tr><td rowspan="4"><img src=<%=temp.getPicture()%>></td>
<td>书名:<a href="viewbook.jsp?bookid=<%=temp.getBookid()%>"><%=trans(temp.getName())%></a></td></tr>
<tr><td>作者:<%=trans(temp.getAuthor())%></td><td>译者:<%=trans(temp.getTranslator())%></td></tr>
<tr><td>价格:<%=temp.getPrice()%></td><td>会员价格:<%=temp.getMemberprice()%></td></tr>
<tr><td>出版社:<%=trans(temp.getPublisher())%></td>
<% int i = temp.getStock();
if(i>0){%>
<td><a href="<%=request.getContextPath()%>/showcart.jsp?Addbook=<%=bookid%>">加入购物车</a></td></tr>
<%}else{%>
<td><a href="noughtbook.jsp">加入购物车</a>&nbsp&nbsp<font color="red">缺货</font></td></tr>
<%} //end of if
a++;
}%>
</table>
</center>
</body>
第<%=intPage%>页   共<%=MaxPage%>页
<%if(intPage>1){%><a href="result.jsp?Page=<%=intPage-1%>">上一页</a><%}%>
<%if(intPage<MaxPage){%><a href="result.jsp?Page=<%=intPage+1%>">下一页</a><%}%>
<%}}catch(Exception e)
{e.printStackTrace();}
%>
</html>
<p>

猜你喜欢