Grails 脚手架默认为每页 10 行。我想增加这个数字而不生成视图并更改每个文件中的 10。在哪里更改默认值?

有帮助吗?

解决方案

您必须安装脚手架模板:

grails 安装模板

现在,编辑 src/templates/scaffolding Controller.groovy 并根据需要增加 params.max 值

其他提示

我发现了这个,但无法让它工作。你应该能够(根据 )到脚手架,然后覆盖控制器中您想要的操作(例如列表),但就像我说的,它对我不起作用......

class PersonController {
  def scaffold = true

  def list = {
    if(!params.max) params.max = 20
    [ personList: Person.list( params ) ]
  }
}

好的,如果您使用动态脚手架解决此错误,请直接在 GRAILS_HOME/src/grails/templates/scaffolding 中编辑

添加到 uri:

?max=<num_rows_desired>

例如:

http://projecthost:8080/Library/Books/list?max=20
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top