期间自己百度了很多,看了网上页面插件,但是没有使用,最后用了比较笨的方法。有很多不足地方希望能被指出
html页面代码:
Title
图书借阅系统---后台管理
图书名称:
新增
图书编号
图书分类
图书名称
作者
出版社
入库时间
是否借阅
操作
共有条数据,当前第/
页
ajax中使用了时间插件jquery-dateformat.js
controller部分代码:
@RequestMapping("/serachName")
@ResponseBody
public Object serachName(String bookName,String pageindex){
String name=bookName;
ListinfoList=null;
int currentPageNo = 1;
int pageSize=4;
if (name==null){
name="";
}
if(pageindex != null){
try{
currentPageNo = Integer.parseInt(pageindex);
}catch(NumberFormatException e){
return "error";
}
}
//总数量
int totalCount=book_infoService.CountListBookByName(name);
//总页数
PageSupport pages=new PageSupport();
pages.setCurrentPageNo(currentPageNo);//当前页码
pages.setPageSize(pageSize); //页面容量
pages.setTotalCount(totalCount); //总数量
int totalPageCount = pages.getTotalPageCount();//总页数
//控制首页和尾页
if(pages.getCurrentPageNo() < 1){
pages.setCurrentPageNo(1);
}else if(pages.getCurrentPageNo() > totalPageCount){
pages.setCurrentPageNo(totalPageCount);
}
int count = (pages.getCurrentPageNo()-1)*pageSize;//当前页码起始下标
System.out.println("---------->>>当前页码:"+pages.getCurrentPageNo());
System.out.println("---------->>>所有数量:"+pages.getTotalCount());
System.out.println("---------->>>所有页数:"+pages.getTotalPageCount());
System.out.println("---------->>>当前页下标:"+count);
System.out.println("---------->>>关键字查询:"+bookName);
infoList=book_infoService.BookEachforName(name,count,pageSize);
Mapmap=new HashMap();
map.put("infoList",infoList);
map.put("bookName",name);
map.put("totalCount",pages.getTotalCount());
map.put("totalPageCount",pages.getTotalPageCount());
map.put("currentPageNo",pages.getCurrentPageNo());
return map;
}
效果: