MyBatis-Spring-Boot icon indicating copy to clipboard operation
MyBatis-Spring-Boot copied to clipboard

大神, 请问可以在controller层动态设置pagesize吗?

Open wtJavaer88 opened this issue 7 years ago • 2 comments

public PageInfo<City> getAll( City city ) { List<City> countryList = cityService.getAll( city ); return new PageInfo<City>( countryList ); } 比如我想每页显示5条, 在查出list以后, 返回之前设置怎么搞?

wtJavaer88 avatar Nov 07 '17 08:11 wtJavaer88

pageSize = 5

abel533 avatar Nov 07 '17 12:11 abel533

    @GetMapping
    public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
        PageHelper.startPage(page, size);
        List<User> list = userService.findAll();
        PageInfo pageInfo = new PageInfo(list);
        return ResultGenerator.genSuccessResult(pageInfo);
    }

wirechen avatar Nov 15 '17 15:11 wirechen