package entity;
import java.util.List;
/**
* 分页结果封装对象
* @author Administrator
*
*/
public class PageResult implements Serializable{
private long total;//总记录数
private List rows;//当前页结果
public PageResult(long total, List rows) {
super();
this.total = total;
this.rows = rows;
}
//getter and setter .....
}
/**
* 返回分页列表
* @return
*/
public PageResult findPage(int pageNum,int pageSize);
@Override
public PageResult findPage(int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
Page<TbBrand> page= (Page<TbBrand>) brandMapper.selectByExample(null);
return new PageResult(page.getTotal(), page.getResult());
}
/**
* 返回全部列表
* @return
*/
@RequestMapping("/findPage")
public PageResult findPage(int page,int rows){
return brandService.findPage(page, rows);
}
<!-- 分页组件开始 -->
<script src="../plugins/angularjs/pagination.js"></script>
<link rel="stylesheet" href="../plugins/angularjs/pagination.css">
<!-- 分页组件结束 -->
var app=angular.module('pinyougou',['pagination']);//定义品优购模块
<!-- 分页 -->
<tm-pagination conf="paginationConf"></tm-pagination>
//重新加载列表 数据
$scope.reloadList=function(){
//切换页码
$scope.findPage( $scope.paginationConf.currentPage,
$scope.paginationConf.itemsPerPage);
}
//分页控件配置
$scope.paginationConf = {
currentPage: 1,
totalItems: 10,
itemsPerPage: 10,
perPageOptions: [10, 20, 30, 40, 50],
onChange: function(){
$scope.reloadList();//重新加载
}
};
//分页
$scope.findPage=function(page,rows){
$http.get('../brand/findPage.do?page='+page+'&rows='+rows).success(
function(response){
$scope.list=response.rows;
$scope.paginationConf.totalItems=response.total;//更新总记录数
}
);
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |