Mapping restful ajax requests to spring
Posted
by Diones
on Stack Overflow
See other posts from Stack Overflow
or by Diones
Published on 2010-05-13T17:39:45Z
Indexed on
2010/05/13
17:44 UTC
Read the original article
Hit count: 176
I have this piece of code:
@RequestMapping(value = "/test.json", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public @ResponseBody Object[] generateFile(@RequestParam String tipo) {
Object[] variaveis = Variavel.getListVariavelByTipo(tipo);
return variaveis;
}
As far as I know it should take a request to test.json?tipo=H and return the JSON representation of Variavel[], however when I make such request I get:
HTTP Status 406 -
type Status report
message
descriptionThe resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ()
By using the following function I can get the expected json:
@RequestMapping(value = "/teste.json")
public void testeJson(Model model, @RequestParam String tipo) {
model.addAttribute("data", Variavel.getListVariavelByTipo("H"));
}
What I'm doing wrong?
© Stack Overflow or respective owner