开发者

Groovy GSP <g:if>

This has been driving me crazy for hours and its probably very obvious to someone ...

Can anyone see why this is printing out even though its reporting as being false?开发者_JS百科

<g:if test="${className == 'SRep'}">
    ${className == 'SRep'}
</g:if> 

If classname==SRep then its correct. However if classname <> SRep it still prints out false? I don't understand how this can be.

If I use ?showSource=true, the if statement looks like this:

if(true && ("false")) {
  printHtmlPart(29)
}
else {
  printHtmlPart(30)
}

Anyone see anything obvious?

Thanks John


your code looks fine but im not sure what 'className' is, perhaps it's not being returned or returning wrong type etc:

i would display the output in the GSP of className just to see what it is e.g. add this anywhere in your GSP:

${className} //displays the value

you may also want to check the object type, in your case i think it should be string so check what you have:

${className?.class} //displays the type of object
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜