title: Angularjs: ngResource can't get the response from SpringData's returns
body: <p>js file:</p>
  
  <pre><code>var app = angular.module('MyApp', ['ngResource']);
  
  
  app.factory('baseRequest', ["$resource", function ($resource) {
  
      return $resource("/apis/getPageData.req/:id")
  
  }]);
  
  
  app.controller("MyCtrl", ["$scope", "baseRequest", function ($scope, baseRequest) {
  
      var self = this;
  
      self.users = [];
  
  
      self.fetchAllUsers = function () {
  
          self.users = baseRequest.query();
  
          console.log(self.users);
      };
  
      self.fetchAllUsers();
  
  }]);
  </code></pre>
  
  <p>SpringMVC controller file:</p>
  
  <pre><code>@RequestMapping("/apis")
  @Controller
  public class UserController {
  
      @Autowired
      private UserDao userDao;
  
  
      @ResponseBody
      @RequestMapping(value = "/getPageData", method = RequestMethod.GET)
      public Page&lt;User&gt; getDatas(@RequestParam(value = "pageNo",required = false,defaultValue = "1"
      ) String No) {
  
          int pageNo = Integer.parseInt(No);
  
          if (pageNo &lt; 0) {
  
              pageNo = 1;
          }
  
          return userDao.getPageData(pageNo);
      }
  
  
      @ResponseBody
      @RequestMapping(value = "/getAll", method = RequestMethod.GET)
      public List&lt;User&gt; getAll() {
  
          return userDao.getAll();
  
      }
  }
  </code></pre>
  
  <p>When I request for the method getAll(), everything goes well. But when I request for the getDatas(), It goes wrong, ngResource can't get the response, it shows me the error as following:</p>
  
  <p>This error occurs when the $resource service expects a response that can be deserialized as an array but receives an object, or vice versa. By default, all resource actions expect objects, except query which expects arrays.</p>
  
  <p>To resolve this error, make sure your $resource configuration matches the actual format of the data returned from the server.</p>
  
  <p><a href="http://i.stack.imgur.com/jRtNU.png" rel="nofollow">error info in console log</a></p>
  
  <p>I don't know how to match the actual format of the data returned from the server.</p>
  
  <p>Actually, I need all the information of Object Page, include the array of User.</p>
  
  <p>Page includes pageNo, currentPage,totallSize,User and so on.</p>