jsp页面可以用分页来控制查询到的多条数据。
具体实例如下:
public class PageResult {
private List list; //装分页列表中的内容
private Integer firstPage; //第一页
private Integer prePage; //上一页
private Integer nextPage;//下一页
private Integer currentPage;//当前页面
private Integer totalPage; //总页数/尾页
private Integer count;//总条数
private Integer size; //每页多少条
public List getList() {
return list;
}
public void setList(List list) {
this.list = list;
}
public Integer getFirstPage() {
return firstPage;
}
public void setFirstPage(Integer firstPage) {
this.firstPage = firstPage;
}
public Integer getPrePage() {
return (this.currentPage-1==0?1:this.currentPage-1);
}
public void setPrePage(Integer prePage) {
this.prePage = prePage;
}
public Integer getNextPage() {
return (this.currentPage==this.totalPage?this.totalPage:this.currentPage+1);
}
public void setNextPage(Integer nextPage) {
this.nextPage = nextPage;
}
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}
public Integer getTotalPage() {
return (this.count%this.size==0?this.count/this.size:this.count/this.size+1);
}
public void setTotalPage(Integer totalPage) {
this.totalPage = totalPage;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Integer getSize() {
return size;
}
public void setSize(Integer size) {
this.size = size;
}
}
public class listServlet extends HttpServlet {
private IProductDAO dao;
@Override
public void init() throws ServletException {
dao = new IProductDAOImpl();
super.init();
}
货品 | 零售价 | 品牌 | 折扣 | 供应商 | 操作 |
---|---|---|---|---|---|
${product.productName} | ${product.salePrice} | ${product.brand} | ${product.cutoff} | ${product.supplier} | 删除 修改 |
首页${pageResult.firstPage} | 上一页${pageResult.prePage} | 下一页${pageResult.nextPage} | 尾页${pageResult.totalPage} | 当前${pageResult.currentPage}/${pageResult.totalPage}页 | 总条数:${pageResult.count} |