您应该将一种模板写入@RequestMapping
:
http://localhost:8080/userGrid?_search=${search}&nd=${nd}&rows=${rows}&page=${page}&sidx=${sidx}&sord=${sord}
现在定义您的业务方法,如下所示:
@RequestMapping("/userGrid?_search=${search}&nd=${nd}&rows=${rows}&page=${page}&sidx=${sidx}&sord=${sord}")
public @ResponseBody GridModel getUsersForGrid(
@RequestParam(value = "search") String search,
@RequestParam(value = "nd") int nd,
@RequestParam(value = "rows") int rows,
@RequestParam(value = "page") int page,
@RequestParam(value = "sidx") int sidx,
@RequestParam(value = "sort") Sort sort) {
...............
}
因此,框架将映射${foo}
到适当@RequestParam
的 .
由于 sort 可能是 asc 或 desc 我将其定义为枚举:
public enum Sort {
asc, desc
}
Spring 很好地处理了枚举。