一直被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>

相关文章:

  • 2021-05-11
  • 2021-08-09
  • 2022-01-22
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-25
  • 2021-10-19
  • 2021-09-29
  • 2022-02-26
  • 2021-11-25
  • 2021-12-02
相关资源
相似解决方案