HTTP状态406–在spring MVC和Angularjs中不可接受

HTTP状态406–在spring MVC和Angularjs中不可接受,angularjs,spring,http,spring-mvc,http-status-code-406,Angularjs,Spring,Http,Spring Mvc,Http Status Code 406,HTTP状态406–不可接受 根据请求中接收到的主动协商标头字段,目标资源没有用户代理可以接受的当前表示,服务器不愿意提供默认表示 控制器代码 @RequestMapping(value="/welcomes", method = RequestMethod.GET, produces="application/json") public @ResponseBody List<UserBean> welcome(@ModelAttribute UserBean userBea

HTTP状态406–不可接受 根据请求中接收到的主动协商标头字段,目标资源没有用户代理可以接受的当前表示,服务器不愿意提供默认表示

控制器代码

@RequestMapping(value="/welcomes", method = RequestMethod.GET, produces="application/json")
    public @ResponseBody List<UserBean> welcome(@ModelAttribute UserBean userBean, HttpServletResponse response)
    {
        List<UserBean> usernames=new ArrayList<UserBean>();
        usernames = retrievedataservice.findAllUsers(userBean);
        System.out.println(usernames.size());
        return usernames;
    }
角js代码

   <script>
    var app = angular.module('myApp', []);
    app.controller('UserController', function($scope, $http, $location){
        $scope.usernames=[];
            var url = $location.absUrl() + "welcomes";
            $http.get(url).then(function (response) 
            {
                $scope.usernames = response.records;
            },function error(response) 
            {
                $scope.postResultMessage = "Error with status: " +  response.statusText;
            });
    });
    </script>
<table border="1" width="50%" height="50%"> 
    <tr><th>user_name</th><th>phone</th><th>email</th></tr>
     <tr data-ng-repeat="user in usernames">
     <td>{{user.username}}</td>
      <td>{{user.phone}}</td>
       <td>{{user.email}}</td>
       </tr>   
   </table> 

如何将数据从spring控制器发送到angular js控制器?

尝试如下更改方法签名

@RequestMapping(value="/welcomes", method = RequestMethod.GET,produces={"application/json"})
    public @ResponseBody List<UserBean> welcome(UserBean userBean, HttpServletResponse response)
提及

<!-- add jackson to support restful API, otherwise the API will return 406 error -->
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.13</version>
    </dependency>