页面数据分页效果
" * FROM product WHERE (id NOT IN (SELECT TOP " +
start +
" id FROM product ORDER BY id DESC ))ORDER BY id DESC";
pstmt=conn.prepareStatement(sql);
res = pstmt.executeQuery();
while(res.next())
{
Product produt=new Product();
produt.setId(res.getInt("id"));
produt.setName(res.getString("name"));
produt.setPictrueUrl(res.getString("pictureUrl"));
produt.setPictureName(res.getString("pictureName"));
produt.setPictureSmailName(res.getString("pictureSmailName"));
produt.setPictureSmailUrl(res.getString("pictureSmailUrl"));
produt.setPrice(res.getString("price"));
produt.setDescript(res.getString("descript"));
list.add(produt);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}finally{
BaseDao.closeAll(conn, pstmt,res);
}
return list;
}
<tr>
<td align="right"> <%
if(pages!=1){
%>
<a href="index.jsp?page=1">第一页</a>
<a href="index.jsp?page=<%=pages-1%>">上一页</a>
<%
}if(pages !=totalCount ){
%>
<a href="index.jsp?page=<%=pages+1%>">下一页</a>
<a href="index.jsp?page=<%=totalCount%>">最后一页</a>
<%
}
%>
<input type="text" size="3" name="page" value="<%=pages%>">
<input type="Submit" name="翻页" value="翻页">
页数:<%=pages %>/<%=totalCount %>
</td>
</tr>
</table>