grails:是否可以仅使用$ {}在gsp页面中进行条件标记 [英] grails: is conditional markup in a gsp page possible just using ${}

查看:60
本文介绍了grails:是否可以仅使用$ {}在gsp页面中进行条件标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Grails当然具有内置的"if"和"else"标记,例如

Grails of course has the built in "if" and "else" tag, e.g.

 <g:if test="${name == 'Fred'}">
     Hello Fred, welcome back from your trip!
 </g:if>
 <g:else>
     Hello ${name}
 </g:else>

是否可以仅在gsp页面上使用$ {}功能来进行类似的事情?不使用

Is it possible to so something like this purely using the ${} capability on a gsp page? Not using the

   <g:if> and 
   <g:else>

标签?

推荐答案

是的,例如像这样:

Hello ${name}${name == "Fred" ? ", welcome back from your trip!" : ""}

这篇关于grails:是否可以仅使用$ {}在gsp页面中进行条件标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆