Use @RequestParam in your method arguments so Spring can bind them, also use the @RequestMapping.params array to narrow the method that will be used by spring. Sample code:
@RequestMapping("/userGrid",
params = {"_search", "nd", "rows", "page", "sidx", "sort"})
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) {
// Stuff here
}
This way Spring will only execute this method if ALL PARAMETERS are present saving you from null checking and related stuff.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…