Reputation: 4088
Searched tons of sites and even stackoverflow but have not found a solution to this problem. Looks like lot of people have encountered this problem but its seems a unified solution is missing that encompasses all the aspect. Have already spent 1.5 days on it.
I see the method is getting invoked but somewhere @ResponseBody
is not getting translated properly. Can someone take a look and let me know what the problem is. I have Uploaded the code on github. Link to source code on github
@RequestMapping(value = "/find_user", method = RequestMethod.GET)
public @ResponseBody List<String> findUser(@RequestParam("term") String name) {
log.info("Search string for user name: " + name);
List<String> users = new ArrayList<String>();
users.add("Sam");
users.add("Dan");
return users;
}
Browser screen shot below with 406 response
Please note: Ah! How painful. This setup works with Spring 3.1.4 and not with 3.2.X
Upvotes: 3
Views: 4562
Reputation: 15204
I also faced up with a same problem. After debugging Spring I found that ServletPathExtensionContentNegotiationStrategy
tries to determine media type based on an extension in the URL. (Probably, because it cannot deduce what media type it should return from Accept
header which contained */*
in my case.)
So, one of the way to fix this is to rename URL in mapping by replacing .html
by .json
.
Upvotes: 2
Reputation: 1350
God, it almost kills me. I tried whatever I can, still stuck there. But finally I figured it out. The reason is Spring, download Spring 3.1.1 and replace all the jars with 3.1.1jars, and it works. All your config is good.
Upvotes: 5