我不确定这是卷曲问题还是圣杯问题--我怀疑是卷曲问题。
如果我用9条记录引导grails 3 rest应用程序并运行curl来列出它们,我就会得到9条记录。
10条引导记录显示10条带有列表卷曲的记录。
11引导记录显示10条记录,并通过curl列出。
那么rest的默认值是10吗?如果是的话,怎样才能改变呢?
控制器代码是由rest配置文件自动生成的,标准也是如此。
package heroes2
class UrlMappings {
static mappings = {
delete "/$controller/$id(.$format)?"(action:"delete")
get "/$controller(.$format)?"(action:"index")
get "/$controller/$id(.$format)?"(action:"show", method: "OPTIONS")
post "/$controller(.$format)?"(action:"save")
put "/$controller/$id(.$format)?"(action:"update")
patch "/$controller/$id(.$format)?"(action:"patch")
"/"(controller: 'application', action:'index')
"500"(view: '/error')
"404"(view: '/notFound')
}
}域是
package heroes2
import grails.rest.*
@Resource(uri = '/heroes', readOnly = false, formats = ['json', 'xml'])
class Hero {
String name
}致以敬意,
发布于 2016-10-07 13:01:56
您的“问题”的来源可能是控制器中的支架式索引-方法中的以下代码(有关max):
def index(Integer max) {
params.max = Math.min(max ?: 10, 100)
respond Hero.list(params), model:[heroCount: Hero.count()]
}您可以在调用中设置偏移量和max参数,如下
/heroes?offset=10&max=30 例如,要使其按页排列
或更改脚手架控制器的代码,或使用
static scaffold=Hero只有方法英雄有:
def heroes() {
respond Hero.list(params)
}https://stackoverflow.com/questions/39912421
复制相似问题