In my current spring project, I have this method in my controller to where I send request from client via method POST:
@RequestMapping(value="cadastra", method=RequestMethod.POST)
@ResponseBody
public String[] cadastra(@ModelAttribute("object") E object, BindingResult result, @RequestParam(value="file", required=false) MultipartFile file, @RequestParam(value="icone", required=false) MultipartFile icone) {
String response[] = {"not", "not", "not"};
if(serv.cadastra(object)) {
response[0] = "yes";
}
if(serv.upload_picture(object, file, "picture")) {
response[1] = "yes";
}
if(serv.upload_picture(object, icone, "icone")) {
response[2] = "yes";
}
return response;
}
In my view, the request is sent through this jquery code:
$('form.form').ajaxForm(function(data) {
$("#"+data[0]).css("display", "block");
$("#image-"+data[1]).css("display", "block");
$("#icone-"+data[2]).css("display", "block");
$('form.form').each(function(){
this.reset();
});
});
but, despite the data from the form are being sent and stored in the server, I got no response, due to an error HTTP 406. Anyone can tell me how I should modify this code to accept the array as response to my request?