How to make the RequestMapping to handle GET parameters in the url? For example i have this url
http://localhost:8080/userGrid?_search=false&nd=135197257
You should write a kind of template into the @RequestMapping:
http://localhost:8080/userGrid?_search=${search}&nd=${nd}&rows=${rows}&page=${page}&sidx=${sidx}&sord=${sord}
Now define your business method like following:
@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) {
...............
}
So, framework will map ${foo} to appropriate @RequestParam.
Since sort may be either asc or desc I'd define it as a enum:
public enum Sort {
asc, desc
}
Spring deals with enums very well.