I have a similar issue as given here . But i cannot solve it with the solutions provided there.
My spring application xml has only mvc annotation driven element.
<mvc:annotation-driven />
The controller code is as given.
@RequestMapping(value = "/search", method = RequestMethod.GET)
public @ResponseBody
Book performSearch(@RequestParam("CHARS") String title) {
return (Book) library.getBook(title);
}
In my javascript I have an jQuery request which tries to get JSON from the url.
<script type="text/javascript">
function doSearch() {
$.getJSON("addBook/search.htm", { CHARS: $('#searchBox').val() }, function(data)
{
alert("Got Response");
$('#results').text('');
for (var index in data) {
$('#results').append('<p>' + data[index].title + '</p>');
}
});
}
</script>
I have a textbox which calls this JS
<input type="text" id="searchBox" onKeyUp="doSearch();" />
<div id="results">Results</div>
While keying in the controller code is called, but the response that comes back has a status code 406 and says Not Acceptable
What could be the problem here? Also can I set the values of "Accept" header to application/json in the jQuery call? If so how?
I am using a locale resolver to resolve the locale. Could this be a problem?
Thanks Dhanush