Spring MVC的控制器返回JSON - 错误406控制器、错误、MVC、Spring

2023-09-10 18:33:13 作者:孤其一身

在搜索StackOverflow的所有相关环节的给定标题后,我张贴了这个问题。

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

我的控制器code是:

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();
    }

和我的jQuery的要求如下:

And My jquery request is as follows:

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

但照常一个406误差在控制台即如下:

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) 

据这里(计算器),发现每一个配置,我检查和复查。 因为过去1小时我一直在争取与问题。任何人可以帮助???

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

推荐答案

发布此,我再次研究后。 我发现,需要两个JAR文件。我将它们添加到CLASSPATH中。

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

杰克逊映射器-ASL-1.7.4.jar 和放大器; 杰克逊核心-ASL-1.7.4.jar

其现在工作的罚款。 Phewwww ....

Its now working fine. Phewwww....