我在gsp中有这样的循环:
<g:each in="${personInstance.followed}" var="c" >
<g:if test="${c.equals(person)}">
<g:link id="${person.id}" action="unfollow" controller="message">unfollow</g:link>
</g:if>
</g:each>
如何在g:each或g:if中使用break?
有任何想法吗?
最佳答案
听起来好像您是根据实例是否在集合中来显示一件事或另一件事。最好的选择是在集合上使用contains
。例如:
<g:if test="${personInstance.followed.contains(person)}">
Display your unfollow stuff here ...
</g:if>
<g:else>
Display your follow stuff here ...
</g:else>
关于html - 打破g:if/g:每个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30855117/