abel533 / MyBatis-Spring-Boot

Spring Boot集成MyBatis的基础项目
3.37k stars 1.59k forks source link

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

Open wtJavaer88 opened 6 years ago

wtJavaer88 commented 6 years ago

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

abel533 commented 6 years ago

pageSize = 5

wirechen commented 6 years ago
    @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);
    }