//后台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页面引用