I have a ng-table in a jsp view that sends to my server the selected params (filtering, sorting, page and pagesize) for every 'getData()' ajax request:
ngTableParams({
page: 1, // show first page
count: 10, // count per page
filter: {
name: 'Mike', // initial filter
age: '18'
},
sorting: {
name: 'asc' // initial sorting
}
}
I want to bind this parameters into java objects in the Spring MVC Controller in order to build dynamic queries in the server.
1: Reading other questions about the REST method for this proposes, I think that I should use: GET better than POST
2: The ngTableParams javascript object for the ng-table has a method 'url' used in their Ajax examples:
ngTableparams.url = Object {page: "1", count: "10", filter[name]: "Mike", filter[age]: "24", sorting[name]: "asc"}
But i'd like to receive all the filter params in just one Array, ¿How can I parse this JSON requestParams easily?.
Controller:
@RequestMapping(value = "/search", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<?> search(@RequestParam(required=true) List<String> filter,
@RequestParam int page,
Locale locale) {
return search(filter, page, locale, null);
}
Thanks!