开发者

Quick PlayFramework / Groovy

开发者 https://www.devze.com 2023-03-09 12:00 出处:网络
Why does the following code always emit \'yes\' (in HTML) even when sel has a different value other than \'audio\'? (I\'ve logged the values of sel and confirmed different values.)

Why does the following code always emit 'yes' (in HTML) even when sel has a different value other than 'audio'? (I've logged the values of sel and confirmed different values.)

This is my day 1 on Play. So, I may be doing something really stupid.

${sel='a开发者_Python百科udio'?'yes':'no'}


I don't know the Groovy templates that well, but I think it should be like this:

${sel=='audio'?'yes':'no'}

Your code:

${sel='audio'?'yes':'no'}

means; if 'audio' (a string that is not null will always be "true") then sel = 'yes' otherwise 'no', so it will never be 'no'.


You might want to look at the yesNo extension: http://www.playframework.org/documentation/1.2.1/javaextensions#yesNo

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号