jsp+java分页问题,在线等,急急急!!! 我把分页做好,并且在jsp页面时用,但是当点击“下一页”时,并没有取得出新内容,而是显示原来的内容,这是为什么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 按考我们教程中关于分页的介绍。http://family168.com/tutorial/jsp/html/jsp-ch-15.html 看看参数是否传过去了试着用debug调试程序。 分页如果嫌烦的化,建议用一个分页组件eXtremetable,这个是开放源代码的,支持导出,用起来简单明了,再有什么复杂的要求,可以自己去扩充它,先去官方网站去下个例子吧。据说jmesa(另外一个分页组件)就是在它的基础上改的。两者都可以看看。 wow!,真是太感谢各位了。我在java里的sql语句是这样:public List findListReply(int page, int topicId) { List list = new ArrayList(); // 用来保存主题对象列表 int pagesize = 20; int rowBegin = 1; // 开始行数,表示每页第一条记录在数据库中的行数 if(page>1){ rowBegin = pagesize * (page - 1); // 按页数取得开始行数,设每页可以显示20条回复 } String sql = " select top " + pagesize + " * from TBL_REPLY where replyId not in(select top " + rowBegin + " replyId from TBL_REPLY where topicId=" + topicId + " order by replyId asc )and topicId="+topicId+" order by replyId asc"; System.out.println(sql); try { conn = this.getConn(); // 获得数据库连接 pstmt = conn.prepareStatement(sql); // 得到一个PreparedStatement对象 rs = pstmt.executeQuery(); // 执行SQL,得到结果集 /* 将结果集中的信息取出保存到list中 */ while (rs.next()) { Reply reply = new Reply(); // 主题对象 reply.setReplyId(rs.getInt("replyId")); reply.setContent(rs.getString("content")); reply.setPublishTime(rs.getString("publishTime")); reply.setModifyTime(rs.getString("modifyTime")); reply.setUid(rs.getInt("uId")); reply.setTopicId(rs.getInt("topicId")); list.add(reply); } } catch (Exception e) { e.printStackTrace(); // 处理异常 } finally { this.closeAll(conn, pstmt, rs); // 释放资源 } return list; }经过测试,已经成功查找并且可以分页查找了。好,希望这一小段代码也能帮助有需要的朋友。结分去啰 hibernate3中批量删除问题(父子表删除) 关于tiles,Tomcat报错,该怎么解决啊? 急,linux下用的pureftpd,怎么开通一个新的ftp用户 怎么判断控件是否安装了呢 WEB在本地生成文件问题? 求fckeditor,JAVA版使用者 根据不同用户信息显示不通页面内容 【求助】MVC能实现客户端打印机打印服务器上的WORD吗? jdbc使用错误,请高手帮忙。 各位有碰到这种情况吗? 数据库连接问题 在Struts2中,如何使用JSTL来读取Action中的变量?
http://family168.com/tutorial/jsp/html/jsp-ch-15.html
试着用debug调试程序。
据说jmesa(另外一个分页组件)就是在它的基础上改的。两者都可以看看。
我在java里的sql语句是这样:
public List findListReply(int page, int topicId) {
List list = new ArrayList(); // 用来保存主题对象列表
int pagesize = 20;
int rowBegin = 1; // 开始行数,表示每页第一条记录在数据库中的行数
if(page>1){
rowBegin = pagesize * (page - 1); // 按页数取得开始行数,设每页可以显示20条回复
}
String sql = " select top " + pagesize
+ " * from TBL_REPLY where replyId not in(select top "
+ rowBegin
+ " replyId from TBL_REPLY where topicId=" + topicId
+ " order by replyId asc )and topicId="+topicId+" order by replyId asc"; System.out.println(sql); try {
conn = this.getConn(); // 获得数据库连接
pstmt = conn.prepareStatement(sql); // 得到一个PreparedStatement对象
rs = pstmt.executeQuery(); // 执行SQL,得到结果集 /* 将结果集中的信息取出保存到list中 */
while (rs.next()) {
Reply reply = new Reply(); // 主题对象
reply.setReplyId(rs.getInt("replyId"));
reply.setContent(rs.getString("content"));
reply.setPublishTime(rs.getString("publishTime"));
reply.setModifyTime(rs.getString("modifyTime"));
reply.setUid(rs.getInt("uId"));
reply.setTopicId(rs.getInt("topicId"));
list.add(reply);
}
} catch (Exception e) {
e.printStackTrace(); // 处理异常
} finally {
this.closeAll(conn, pstmt, rs); // 释放资源
}
return list;
}经过测试,已经成功查找并且可以分页查找了。
好,希望这一小段代码也能帮助有需要的朋友。结分去啰