java分页
来源:互联网 发布:seo搜索优化软件 编辑:程序博客网 时间:2024/06/15 16:17
entity:
package com.mlnx.base.entity;import java.io.Serializable;import java.util.List;/** * 页面分页类 * * @author Roy * */public class PageUtil implements Serializable {private static final long serialVersionUID = 1L;private int curPage;// 当前页private int tolPage;// 总页数private int pageSize = 2;// 一页多少条private int tolRecord;// 总数private List<TApp> app;public List<TApp> getApp() {return app;}public void setApp(List<TApp> app) {this.app = app;}public void countTolPage(int record) {this.tolRecord = record;if (this.tolRecord % this.pageSize == 0) {this.tolPage = this.tolRecord / this.pageSize;} else if (this.tolRecord < this.pageSize) {this.tolPage = 1;} else {this.tolPage = this.tolRecord / this.pageSize + 1;}}public int getCurPage() {return curPage;}public void setCurPage(int curPage) {this.curPage = curPage;}public int getTolPage() {return tolPage;}public void setTolPage(int tolPage) {this.tolPage = tolPage;}public int getPageSize() {return pageSize;}public void setPageSize(int pageSize) {this.pageSize = pageSize;}public int getTolRecord() {return tolRecord;}public void setTolRecord(int tolRecord) {this.tolRecord = tolRecord;}}
col:<pre class="html" name="code">public class PageCol {@Autowired private AppServise appServise;@RequestMapping(value ="firstPage")public ModelAndView getFirstPage(HttpServletRequest request){PageUtil pu=new PageUtil();int record=appServise.countTolNum();pu.setTolRecord(record);pu.countTolPage(record);pu.setCurPage(1);pu.setApp(appServise.findTappByLimit(0, pu.getPageSize()));ModelAndView mav=new ModelAndView("hello");mav.addObject("pu", pu);return mav;}}页面:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><!DOCTYPE html><html><head><title>分页测试</title></head><body><table><c:forEach items="${pu.app}" var="app"><tr><td>${app.id}</td><td>${app.name}</td><td>${app.version}</td><td>${app.stable}</td><td>${app.date}></td><td>${app.path}</td></tr></c:forEach> </table> <a href="firstPage">首页</a> <a href ="lastPge?curPage=${pu.curPage}">上一页</a> <a href ="nextPge?curPage=${pu.curPage}">下一页</a> <a href ="endPge?curPage=${pu.curPage}">尾页</a> 第${pu.curPage}页/共${pu.tolPage}>页 </body></html>
0 0
- java分页
- java分页
- java 分页
- java分页
- java 分页
- java分页
- java 分页
- java 分页
- java分页
- java 分页
- java分页
- Java分页
- Java分页
- java分页
- java 分页
- java分页
- Java分页
- java 分页
- 2719 sheldon数
- printf和scanf的*修饰符
- Android多线程下载SDK的设计,支持断点续传
- 杨辉三角
- 拿什么守护你的Node.JS进程: Node出错崩溃了怎么办?
- java分页
- 关于shell脚本里的单行注释和多行注释方法
- Android TextView解析HTML内容
- 文章标题
- SpringMVC中使用Interceptor拦截器
- redhat命令操作(三)
- 完全卸载VS2013
- 我是手游开发者(二) 与开发常见web应用(如网站)之间的异同
- Android添加快捷方式(Short)到手机桌面