Clad head, and can not think! You help me! Thank you! jsp Pagination problem

Category: Web Develop
 
rpg1164557
2012-04-14 01:49:45

Sponsored Links

<jsp:useBean id="showmp3" scope="page" class="firm.firm"/>
<%
int pageline = 8; / / how many rows a
int totalRec = 0; / / total number of
int intpage = 1; ; / / this page
int totalsub = 0;
int i = 1;
try {
; ResultSet ru = showmp3.executeQuery ("select count (*) as cnt From user");
if (ru.next () )
totalRec = ru.getInt ("cnt"); / / take the total number of records
ru.close ();
; showmp3.closeStmt ();
}
catch (SQLException e)
{
e.printStackTrace ();
}
int totalpage = 0; / / take the total number of pages
totalpage = (totalRec + pageline-1) / pageline;
%>
<table>

<%! String id, name, picture, detail, sql;%>
<%
sql = "select * From user order by id";
ResultSet rs = showmp3.executeQuery (sql);
%>
<%
if (totalpage> 0) {
for (i = 1; i <= (intpage-1) * pageline; i + +)
rs.next ();
out.print ("<tr>");
for (i = 1; i <= pageline; i + +) {
if (rs.next ()) {
id = rs.getString ("id");
name = rs . getString ("name");
picture = rs.getString ("picture");
out.print ("<td ; width = '20% 'align =' center '> "+ name +" <br> <img align = center width = 100 height = 120 alt =' No image ' ");
out.print (" src = cpimages / ");
out.print (picture);
; out.print ("> </td>");
}
if (i == 4)
out.print ("</tr> <tr>");
if (i == pageline)
out.print ("</tr>" );

} rs.close ();
}%>

<% / / The following is the pager
out.print ("<tr>");
if (totalpage * pageline <totalRec)
totalpage + +;
if (intpage> totalpage)
intpage = totalpage;
if (intpage <1)
intpage = 1;

if (intpage <2) {
out.print ("<td align=center> Home Previous </td> ");
} else
{
out.print (" <a href='view.jsp?page=1'> Home </a> <");
out.print (" <a href = 'view.jsp? page = "+ (intpage-1) +" '> Previous </a> ");
}
if (intpage-totalpage> = 0) {
out.print ("<td> Next Last </td>");}
else {
; out.print ("<a href='view.jsp?page="+(intpage+1)+"'> Next </a> <a href = 'view . jsp? page = "+ intpage +" '> Last page </a> ");

}
out.print (" ; </td> ");
%>
</table>
These are part of the code, why, when data is more than one data displayed when I click next Page Why it always shows the first page!

Sponsored Links

chukai_foreverone
2012-04-14 02:25:11
I do not see how you get page ah?
monicaxixi
2012-04-14 02:55:03
you do not get back the page information, the program should begin to retrieve the current page from the request message.
liyanhaomei
2012-04-14 03:27:45
with parameter control when there are problems.
tongji11tongji
2012-04-14 03:46:39
when the program starts you have to take the current page?
And every time intpage initially one of the! !
frankieyu588
2012-04-14 04:14:37
take data on the phrase on it the day before yesterday (first time to add the page parameter no judgment)
intpage = request.getParameter ("page");
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.