java代码封装分页_java 分页封装类

//后台Page.java

package com.complaints.util;5

import java.util.List;

import java.util.Map;

public class Page {

private String pageBar;

private int pageCount;//页总数

private int rowCount;//总行数

private int pagesize = 10;//每页显示的数据记录

private int curPage;//当前页

private int first;//首页

private int prev;//上一页

private int next;//下一页

private int last;//定义每一页的结束 end

private List> list;//储存查询的结果集

public String getPageBar() {

return pageBar;

public void setPageBar(String pageBar) {

String str;

str = "

str+="

共 ";

str+=""+this.getPageCount() +" 页,";

str+=""+this.getRowCount() +" 条数据,";

str+="当前第 "+this.getCurPage()+" 页     ";

if(isFirst()){

str+="首页   上一页";

}else{

str+="首页 上一页";

if(isLast()){

str+="下一页  末页";

}else{

str+="下一页 末页";

this.pageBar = str;

public boolean isLast() {

return (this.getCurPage() == this.getPageCount()) ? true : false;

public boolean isFirst() {

return (this.getCurPage() == 1) ? true : false;

public int getFirst() {

this.first=1;

return first;

public void setFirst(int first) {

this.first = first;

public int getLast() {

this.last=(int) this.getPageCount();

return last;

public void setLast(int last) {

this.last = last;

public int getPageCount() {

this.pageCount= (int) Math.ceil((double) this.getRowCount()/(double)     this.getPagesize());

return pageCount;

public void setPageCount(int pageCount) {

this.pageCount = pageCount;

public int getRowCount() {

return rowCount;

public void setRowCount(int rowCount) {

this.rowCount = rowCount;

public int getPagesize() {

return pagesize;

public void setPagesize(int pagesize) {

this.pagesize = pagesize;

public int getCurPage() {

return curPage==0?1:curPage;

public void setCurPage(int curPage) {

this.curPage = curPage;

public int getPrev() {

this.prev=(this.getCurPage()>1)?(this.getCurPage()-1):1;

return prev;

public void setPrev(int prev) {

this.prev = prev;

public int getNext() {

this.next=(this.getCurPage() < this.getPageCount()) ? (this.getCurPage()+1):this.getCurPage();

return next;

public void setNext(int next) {

this.next = next;

public List> getList() {

return list;

public void setList(List> list) {

this.list = list;

//action中引用

package com.complaints.web;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.ui.ModelMap;

import org.springframework.web.bind.annotation.ModelAttribute;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.servlet.ModelAndView;

import com.complaints.po.User;http://www.huiyi8.com/jiaoben/javascript特效

import com.complaints.service.UserService;

import com.complaints.util.Page;

@Controller

public class UserController {

@Autowired

private UserService userservice;

@RequestMapping("user/list")

public ModelAndView GetStateList(@ModelAttribute("user") User user,

@ModelAttribute("page") Page page){

page=userservice.listState(user, page);

page.setPageBar("");

ModelMap mp=new ModelMap();

mp.put("page",page);

ModelAndView mav = new ModelAndView("user/List_state",mp);

return mav;

//jsp页面引用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值