grails:是gsp页面中的条件标记,只需使用$ {}

时间:2013-10-17 20:52:03

标签: grails gsp

Grails当然有内置的“if”和“else”标签,例如

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

是否有可能在gsp页面上纯粹使用$ {}功能?不使用

   <g:if> and 
   <g:else>

标签?

1 个答案:

答案 0 :(得分:4)

是的,例如像这样:

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