在iOS RestKit中,我们有RKPaginator来实现分页。我们在RestLet中有没有类似的东西来实现分页逻辑?
谢谢。
发布于 2015-01-20 22:24:12
Restlet不支持分页。它是一个REST框架,您可以利用查询参数或头来实现这样的功能。有关更多详细信息,请参阅本文的“过滤数据”部分:https://templth.wordpress.com/2014/12/15/designing-a-web-api/。
希望能有所帮助。蒂埃里
发布于 2015-09-03 01:31:13
也许它仍然有帮助..。
如果您想对一个子活动列表进行分页,您的客户端将对您的一个端点执行一个GET请求。让我们说“/feed/feeds/activities”。端点将返回以下JSON文档:
{
href: "http://localhost:8080/feeds/kids/activities",
offset: 0,
limit: 25,
sortBy: "createdAt",
sortOrder: "asc",
first: {
href: "http://localhost:8080/feeds/kids/activities?offset=0&limit=25&sortOrder=asc&sortBy=createdAt"
},
next: {
href: "http://localhost:8080/feeds/kids/activities?offset=25&limit=25&sortOrder=asc&sortBy=createdAt"
},
last: {
href: "http://localhost:8080/feeds/kids/activities?offset=47150&limit=25&sortOrder=asc&sortBy=createdAt"
},
items: [
{
_id: "55dc6064d6931a786b137acd",
name: "Coloring",
feedName: "kidActivity",
}
....
]
}..。如果定义了next、last、first字段,则使用href属性回调subsecquent项。您可以使用URL参数在后端配置数据库查询。
我觉得很有用的Lee Hazlewood did a video。
https://stackoverflow.com/questions/19267380
复制相似问题