我不确定这是卷曲还是grails问题 - 我怀疑是grails。
如果我使用9条记录引导grails 3 rest应用程序并运行curl列出它们,我会得到9条记录。
10个引导记录显示列表卷曲的10条记录。
11个引导记录显示10条记录,并通过curl列出。
那么其余api的默认值是10吗?如果是这样,怎么改变?
控制器代码由静止配置文件自动生成,因此是标准配置。
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
}
此致
答案 0 :(得分:0)
你问题的根源"可能是您控制器中 scaffolded 索引方法中的以下代码(关于max):
data-translate="entity.action.edit"
您可以在通话中设置偏移和最大参数
def index(Integer max) {
params.max = Math.min(max ?: 10, 100)
respond Hero.list(params), model:[heroCount: Hero.count()]
}
例如,以页面方式获取
或更改脚手架控制器的代码或使用
创建控制器/heroes?offset=10&max=30
并且只有方法英雄:
static scaffold=Hero