求一个清晰点的action jsp分页显示的方法。。。。。。。。。

lqsmn613 lqsmn613 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如题,忘记怎么写分页的了。大家来个好点的,下面是我action中获取数据的一个方法:

public ActionForward doView2(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
DynaActionForm dyForm = (DynaActionForm) form;
com.ebuilds.util.common.LoginInfo logininfo = (com.ebuilds.util.common.LoginInfo) request.getSession().getAttribute("LoginInfo");
String username = logininfo.getName();
String uid = null;
List list = new ArrayList();
try {
DB db = new DB();
ResultSet rs = db.qu("select * from userinfo where username = '" +
username+"'");
while(rs.next()){
uid = rs.getString("id");
}
if(uid != null){
ResultSet rs1 = db.qu("select * from userinfo where pid = '" +
uid+"'");
while(rs1.next()){
Map map = new HashMap();
map.put("id", rs1.getString("id"));
map.put("pid", rs1.getString("pid"));
map.put("username", rs1.getString("username"));
map.put("name", rs1.getString("name"));
list.add(map);
}
}
db.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
dyForm.set("dtos", list);
return mapping.findForward("doView2");
}


根据上面action中取得的list集合的数据,在jsp中需要用分页来显示,每页14条。分页按钮中分别有:
第一页,上一页,下一页,最后页,转至 第__页 显示1到14条记录 第1页共2页

大家别藏私啊,来个好点的,最后带点代码说明,看的没这么累。多谢。
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
lqsmn613
Web 开发 81,108 成员 341,721 内容