grails中添加自定义标签解决gsp页面双层循环问题
Nope, not with the each clause.
I'd just write my own taglib that takes list1 and list2 and does the iteration for you, yielding back to the
<g:eachCheckedItem list1="${list1}" list2="${list2}"> <input type="checkbox" ... checked="checked"/></g:eachCheckedItem>
def eachCheckedItem = { attrs, body -> def list1 = attrs.list1 def list2 = attrs.list2 list1.findAll { list2.contains(it) }.each { out << body(listItem: it) // access to listItem variable inside gsp }}