TableGridService
依赖于工具类 GridUtils
,可以在 Controller
层,通过SQL构造对象,直接从 HttpServletRequest
获取请求参数。
@GetMapping("request")
public Grid request(HttpServletRequest request) {
return new DefaultTableGridService("SELECT id, title, work_time FROM t_demo WHERE title like :title")
.list(request);
}
也可以手动指定查询count的SQL,提高查询效率。
@GetMapping("request")
public Grid request(HttpServletRequest request) {
return new DefaultTableGridService("SELECT id, title, work_time FROM t_demo WHERE title like :title",
"SELECT count(*) FROM t_demo WHERE title like :title")
.list(request);
}