I am trying to send a complex object to ajax controller for spring mvc search engine, with 3 variables: the current page, items per page and the search parameters. The problem is that with the declaration of the controller method does not take me the params variable as a Map.
As I can send the structure to collect on the controller 3 variables separately?
Error:
Required Map parameter 'params' is not present
var dataToSend = {
'page': 1,
'itemsPerPage': 10,
'params': {
'codItem': "10",
'nameItem': "foo"
}
};
$.ajax({
url: form.attr("action"),
type: 'POST',
data: JSON.stringify(dataToSend),
dataType: 'json',
cache: false
}).success(function(data) {
callback(data);
});
public @ResponseBody HashMap<String, Object> search(@RequestParam(value="params") Map<String, String> params, @RequestParam(value = "page") int page, @RequestParam(value = "itemsPerPage") int itemsPerPage){
};