由请求识别的资源只能根据请求产生具有不可接受的特征的响应"接受"头

时间:2014-08-12 14:16:11

标签: jquery ajax json spring-mvc

我的控制器方法如下:

@RequestMapping(value = "/instances",method = RequestMethod.GET)
public @ResponseBody Set<ArchivalInstance> findAllInstances() {
    System.out.println("finding all instances");
    Set<ArchivalInstance> set=archivalInstanceService.getAllArchivalInstance();
    return set;
}

和jj中的ajax调用

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(
                function() {
                    $.getJSON('instances.html', {
                        ajax : 'true'
                    }, function(data) {
                        alert("data ="+data.instanceName);
                    });
                });
    </script>

当我在开发者工具(在Chrome浏览器中)中看到网络选项卡时,我收到了以下错误

<Response>
    The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers


<header>
    Request URL:http://localhost:8082/ArchivalSearchTool/instances.html?ajax=true
    Request Method:GET
    Status Code:406 Not Acceptable
    Request Headersview source
    Accept:application/json, text/javascript, */*; q=0.01 

我试图返回boolean而不是set但无法获得响应。请告诉我需要更改的地方或需要添加任何罐子?

0 个答案:

没有答案