Search code examples
jqueryajaxjsonspring-mvcspring-roo

Spring MVC Controller Return JSON - Error 406


After searching all the related links in StackOverflow for the given title I am posting this question.

My Controller code is:

@RequestMapping(value="/user/update", method = RequestMethod.GET, headers="Accept=*/*")
    public @ResponseBody List<Users> getContentSummaryData(@RequestParam String user, @RequestParam String userid){
        return Users.findAllUsers();
    }

And My jquery request is as follows:

$.getJSON("user/update", { user: "user", userid:"1230" }, function(data){
        console.log(data);
    });

But as usual a 406 error in console which is as follows:

GET http://localhost:8080/mycontext/user/update?user=user&userid=1230 406 (Not Acceptable) 

According to every configuration found in here(StackOverflow), I checked and rechecked. I have been fighting with problem since past 1 hour. Can anybody help???


Solution

  • After posting this I researched again. I found that two JARs required. I added them to classpath.

    jackson-mapper-asl-1.7.4.jar & jackson-core-asl-1.7.4.jar

    Its now working fine. Phewwww....