I am trying to get JSON response from spring controller by AJAX call in jsp. Below is code.
Spring MVC Controller:
@RequestMapping(value = "/data.htm", method = RequestMethod.GET, headers="Accept=*/*",consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public TestVO testMe(){
TestVO testVO = manageService.getData(2);
return testVO ; //I am getting testVo but after returning from here I am getting 406 Not Acceptable issue
}
Ajax call in JSP:
$.ajax({
url: url2,
type: "GET",
beforeSend: function(xhr) {
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
},
success: function(smartphone) {alert("hi");
}
});
Please suggest for solution.
Regards