Spring MVC Controller Return JSON - Error 406

百般思念 提交于 2019-12-12 03:35:31

问题


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???


回答1:


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....



来源:https://stackoverflow.com/questions/14345505/spring-mvc-controller-return-json-error-406

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!