• 自定义异常,需要手动抛出。 | @GetMapping(value = “/pageTeacher/{current}/{limit}”)
      public R pageListTeacher(@ApiParam(name = “current”, value = “当前页码”, required = true)
      @PathVariable Long current,
      @ApiParam(name = “limit”, value = “每页记录数”, required = true)
      @PathVariable Long limit){
      try {
      int a = 10/0;
      } catch (Exception e) {
      //传入参数2001,自定义异常
      throw new GuliException(2001,“自定义异常!”);
      }
      Page pageTeacher = new Page<>(current,limit);
      //调用 page() 方法时候,底层封装,把分页所有数据封装到 pageTeacher
      eduTeacherService.page(pageTeacher, null);

      long total = pageTeacher.getTotal();//总记录数
      List records = pageTeacher.getRecords();//数据的list集合
      return R.ok().data(“total”,total).data(“rows”,records);
      } | | —- |

    idea控制台输出:
    image.png
    swagger测试:
    image.png