我在服务器端有方法:
@RequestMapping(method = RequestMethod.GET)
public List<UserDTO> getAllUsers(@RequestParam(value = "groupId", required = false) Long groupId,
@RequestParam(value = "pagination") Pagination pagination){
// some stuff
}
我尝试从客户端发送数据Restangular
:
function getUsers(filters){
restService.all("users").getList(filters).then(function(users){
$scope.data.users = users;
});
}
// ....
getUsers({groupId: undefined, pagination: $scope.data.pagination});
pagination
可以在哪里:
$scope.data = {
// Other parameters
pagination: {
currentPage: 1,
totalItems: 30,
itemsPerPage: 5
}
};
但我得到了:
Failed to convert value of type 'java.lang.String'
to required type 'pagination.Pagination';
当我寻找时,Request URL
我看到:
http://localhost:8080/skp/users?pagination=%7B%22currentPage%22:1,%22totalItems%22:30,%22itemsPerPage%22:5%7D
并且Query String Parameters
是:
pagination:{"currentPage":1,"totalItems":30,"itemsPerPage":5}
我希望应该将分页对象发送到服务器端,但它尝试发送字符串而不是对象。是否知道如何使用 HTTPGET
方法和getList
Restangular
方法发送参数不是 as Query String
,我认为这会导致我的问题?或者如何让服务器端将其视为Pagination
对象,而不是字符串?非常感谢您的回答