html - 打破g:if/g:每个

标签 html grails gsp

我在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/

相关文章:

javascript - 使用 PHP 和 AJAX 获取页面名称而不是页码

grails - Grails-带有版本号的Maven建筑大战

javascript - 在Grails中导入HTML模板

Grails GSP 编译?

grails - Grails与参数和确认链接

html - 可见性隐藏在 AngularJs 中?

java - html5 : Write content to a page without refreshing

html - 使用 CSS3 选择除最后一类之外的所有行

grails - Grails-在重定向参数中发送对象列表

grails - 如何总结 Grails/GSP 中的值