Spring MVC的控制器返回JSON - 错误406 [英] Spring MVC Controller Return JSON - Error 406

查看:195
本文介绍了Spring MVC的控制器返回JSON - 错误406的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在搜索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.

<一个href="http://repo1.maven.org/maven2/org/$c$chaus/jackson/jackson-core-asl/1.7.4/jackson-core-asl-1.7.4.jar"相对=nofollow>杰克逊映射器-ASL-1.7.4.jar 和放大器; <一href="http://repo1.maven.org/maven2/org/$c$chaus/jackson/jackson-core-asl/1.7.4/jackson-core-asl-1.7.4.jar"相对=nofollow>杰克逊核心-ASL-1.7.4.jar

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

Its now working fine. Phewwww....

这篇关于Spring MVC的控制器返回JSON - 错误406的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆