本文介绍了< g:if>逻辑或条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在gils gsp中,而不是

In grails gsp, instead of

<g:if env="development">
     <H1> xyz </H2>
</g:if>
<g:if env="production">
     <H1> xyz </H2>
</g:if>

是否可以编写逻辑或条件以结合这两个条件

is it possible to write logical or condition in to combine the two conditions

例如

<g:if test="env='production'"||"env='devlopment'">
    <H1> xyz </H2>
</g:if>

这样做的正确方法是什么?现在我有错误.

What's the right way of doing that? Right now I am having errors.

谢谢

推荐答案

仅出于DRYness:

Just for the sake of DRYness:

<%@ page import="grails.util.Environment" %>
<g:if test="${Environment.current in
                [Environment.PRODUCTION, Environment.DEVELOPMENT]}">
    <h1>xyz</h1>
</g:if>

这篇关于&lt; g:if&gt;逻辑或条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-27 07:50
查看更多