java分页排序,Spring MVC 4中的分页和排序

试试这种方式:

findAll方法带参数"PageRequest()"提供服务器端分页

有两种方法

PageRequest(int page,int size)

PageRequest(int page,int size,Direction direction,String ... properties)

查看:

DispatureServiceHostValue

{{x.dispature}}{{x.service}}{{x.host}}{{x.value}}

total-items="app.totalItems" boundary-link-numbers="true"

ng-model="app.currentPage" rotate="false" max-size="app.maxSize"

class="pagination-sm" boundary-links="true"

ng-click="app.getPagableRecords()">

Page: {{app.currentPage}} / {{numPages}}

Js控制器:

app.controller('AllEntryCtrl',['$scope','$http','$timeout','$rootScope', function($scope,$http,$timeout,$rootScope){

var app = this;

app.currentPage = 1;

app.maxSize = 5;

app.itemPerPage = 5;

app.totalItems = 0;

app.countRecords = function() {

$http.get("countRecord")

.success(function(data,status,headers,config){

app.totalItems = data;

})

.error(function(data,status,header,config){

console.log(data);

});

};

app.getPagableRecords = function() {

var param = {

page : app.currentPage,

size : app.itemPerPage

};

$http.get("allRecordPagination",{params : param})

.success(function(data,status,headers,config){

app.metricsList = data.content;

})

.error(function(data,status,header,config){

console.log(data);

});

};

app.countRecords();

app.getPagableRecords();

}]);

控制器:

@RestController

public class HomeController {

@Autowired

private HomeRepo repo;

@RequestMapping(value = "allRecordPagination", method = RequestMethod.GET)

public Page getAllRecordPagination(@RequestParam("page") int page, @RequestParam("size") int size){

return repo.findAll(new PageRequest(page-1, size));

}

}

存储库:

@Repository

public interface HomeRepo extends JpaRepository

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值