Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails标记库每个循环_Grails - Fatal编程技术网

Grails标记库每个循环

Grails标记库每个循环,grails,Grails,我试图通过taglib获得每个循环的索引值。 示例:这是粗略的伪代码 data.each() { item -> def index out << "<option value='${item.name}'>item.name</option>" } 因此,数据只是一个对象数组。我要做的是尝试获取每个循环中每个项目的索引 使用每个Withindex很容易做到这一点 data.eachWithIn

我试图通过taglib获得每个循环的索引值。 示例:这是粗略的伪代码

        data.each() { item ->
            def index
out << "<option value='${item.name}'>item.name</option>"

        }

因此,数据只是一个对象数组。我要做的是尝试获取每个循环中每个项目的索引

使用每个Withindex很容易做到这一点

data.eachWithIndex { item, idx ->
  out << "<option value='${item.name}'>${item.name}  - ${idx}</option>"
}