1
I have a WS written in Spring that takes an object as a filter and returns a data list.
in my Java Service:
@ResponseBody
@RequestMapping(value="/{filtro}",method=RequestMethod.GET)
public Datatable listar(@RequestBody PessoaFiltro filtro) throws Exception {
/*Codigo não importante omitido aqui*/
}
in my Service Angularjs:
angular.module('datatablePessoaFactory', ['ngResource'])
.factory('datatablePessoaService', function($resource) {
var recurso = $resource('/datatable-pessoa/:filtro', {filtro:'@filtro'},
{'update': { method:'PUT'}
}
);
return recurso;
}
);
the call in the JS controller:
datatablePessoaService.get({'filtro':vm.filtro},
function(dados){
vm.datatablePessoas = dados;
},
function(erro){
console.log(erro);
}
);
however I can not perform the query, because, as far as I could understand, the GET method does not accept the passage of complex objects.
and I see in my console the error:
datatable-person/%5Bobject%20Object%5D Failed to load Resource: the server responded with a status of 405 (Method Not Allowed)
then my question is: How can I make a query in which it is necessary to pass a complex object?
I’ll risk pq not knowing java, but it seems q the route gets GET and vc is passing PUT, resulting in the method not allowed according to the error returned. If you put it in JS " {'update': { method:'GET'} " it will not solve ?
– Luiz Pillon