//分页查询功能
@ApiOperation(value = "根据讲师进行分页查询")
@GetMapping("pageTeacher/{current}/{limit}")
public R pageTeacher(@ApiParam(name = "current", value = "当前页码", required = true) @PathVariable long current,
@ApiParam(name = "limit", value = "每条记录数", required = true) @PathVariable long limit) {
Page<EduTeacher> teacherPage = new Page<EduTeacher>(current, limit);
int i=1/0;//自己加的异常报错
eduTeacherService.page(teacherPage, null);
long total = teacherPage.getTotal();
List<EduTeacher> records = teacherPage.getRecords();
return R.ok().data("total", total).data("records", records);
}
//指定异常
@ResponseBody//返回数据
@ExceptionHandler(ArithmeticException.class)//
public R error(ArithmeticException e) {
e.printStackTrace();
return R.error().message("进行了ArithmeticException异常处理.....");
}
输出结果