Log4X

链路纵横
[搬家文]struts2/webwork的标签果然是没有最恶心只有更恶心
一直被struts2很没规律的标签搞得很头大,今天终于遇到迄今最恶心的一个问题了
有个if判断字符串是否相等的标签,一直没法正常工作,折腾半个下午...
终于网上某FAQ上找到答案

Why won't the 'if' tag evaluate a one char string?


<ww:if test="#myObj.myString == 'A'">Why doesn't this work when myString is equal to A?</ww:if>
OGNL will interpret 'A' as a char type and not a string. Simple solution - flip the double and single quotes.
<ww:if test='#myObj.myString == "A"'>This works!</ww:if>

Alternatively, you can escape the double quotes in the String:

<ww:if test="#myObj.myString == \"A\"">This works!</ww:if>

posted on 2008-08-13 20:48  YYX  阅读(368)  评论(0编辑  收藏  举报