您可以查看 EL(表达式语言)描述 here。
您的两个代码都是正确的,但我更喜欢第二个,因为将布尔值与 true
或 false
进行比较是多余的。
为了提高可读性,您还可以使用 not
运算符:
<c:if test="${not theBooleanVariable}">It's false!</c:if>
两者都有效。您可以写 eq
而不是 ==
你也可以这样检查
<c:if test="${theBooleanVariable ne true}">It's false!</c:if>