郁闷死 我了,做了一天了,还是没有做出来,上网查资料了,用ResultSet结果集的方法显示分页,我能看懂,没有做呢,但是我现在的困惑是用集合显示分页问题。
在主页上面定义了一个表单,
在新的页面接受表单输入的值,(性别·年龄·地址)
根据 性别·年龄·地址 查询所有信息。
然后,我查询的每一条信息放到一个实体对象中,然后放到了ArrayList 集合中了,
显示信息,然后定义了分页显示5条记录,,
但是点击“下一页”的时候报错,我传的值是对的,但是涉及到查询的3个条件,
<a href="select.jsp?pageid=<%=intPage+1 %>">下一页</a>
不能查看下一页,只有把主页的表单中的 <form action="select.jsp?pageid=2">中的pageid改为2,就显示第二页,
如果在新页面单击“下一页”的时候只有pageid一个值,没有性别,年龄,和地址的值,这个可怎么办啊??
请教高手,小弟感激不尽!
在主页上面定义了一个表单,
在新的页面接受表单输入的值,(性别·年龄·地址)
根据 性别·年龄·地址 查询所有信息。
然后,我查询的每一条信息放到一个实体对象中,然后放到了ArrayList 集合中了,
显示信息,然后定义了分页显示5条记录,,
但是点击“下一页”的时候报错,我传的值是对的,但是涉及到查询的3个条件,
<a href="select.jsp?pageid=<%=intPage+1 %>">下一页</a>
不能查看下一页,只有把主页的表单中的 <form action="select.jsp?pageid=2">中的pageid改为2,就显示第二页,
如果在新页面单击“下一页”的时候只有pageid一个值,没有性别,年龄,和地址的值,这个可怎么办啊??
请教高手,小弟感激不尽!
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ page import="conn.DBO" %>
<%@ page import="mesg.UserMesg" %>
<html>
<head>
<title>浏览信息</title>
</head>
<body>
<%
try{String title = request.getParameter("title");
out.print(title);
String name=(String)session.getAttribute("username");
ArrayList mr=new ArrayList();
UserMesg um=null;
String sql="select * from mesg ";
DBO mc=new DBO();
mc.getConnection();
mr=(ArrayList)mc.Query(sql);
int num=mr.size();
int dipage=1;
int countPageRecord=5;
int countRecord=num;
int countPage=0;
int currentRecord;
String pages=request.getParameter("dipage");
if(pages==null||pages.equals(""))
pages="1";
try{
dipage=Integer.parseInt(pages);}
catch(Exception e){
dipage=1;}
if(countRecord%countPageRecord==0)
countPage=countRecord/countPageRecord;
else
countPage=countRecord/countPageRecord+1;
if(dipage==1)
currentRecord=num;
else
currentRecord=countRecord-(dipage-1)*5;
out.print("<table width='85%' border='1' >");
out.print("<tr><td colspan='2' align='center'><h2>留言信息</h2></td></tr>");
for(int i=0;i<countPageRecord;i++){
um=(UserMesg)mr.get(currentRecord-1);
out.print("<br>");
out.print("<td width='%20'>");
out.print(um.getMesgname());
out.print("<br><br>");
out.print(um.getMesgdate());
out.print("</td>");
out.print("<td width='%80'>");
out.print("<h4>主题:"+um.getMesgsubject()+"</h4>");
out.print("<br>");
out.print(" "+um.getMesgcontent());
out.print("<br>");
out.print(" <a href='del.jsp?mesgId="+um.getMesgId()+"'>删除</a>");
out.print(" <a href='update.jsp?msgid="+um.getMesgId()+"'>更新</a>");
out.print("</td>");
out.print("</tr>");
if(i==countPageRecord)
break;
}out.print("</table>");
out.print("共"+countPage+"页"+"当前第"+dipage+"页");
if(dipage==1)
;
else
{
out.print("<a href=watchAll.jsp?dipage='1'>首页</a>");
out.print("<a href=watchAll.jsp?dipage="+(dipage-1)+">上一页</a>");
}
if(dipage==countPage){
;}
else
{
out.print("<a href=watchAll.jsp?dipage="+(dipage+1)+">下一页</a>");
out.print("<a href=watchAll.jsp?dipage="+countPage+">末页</a>");
}
}
catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>