How to check a boolean condition in EL?

后端 未结 3 380
滥情空心
滥情空心 2020-11-30 23:40

Is this correct?

It\'s false!

Or could I do this?



        
相关标签:
3条回答
  • 2020-12-01 00:14

    You can have a look at the EL (expression language) description here.

    Both your code are correct, but I prefer the second one, as comparing a boolean to true or false is redundant.

    For better readibility, you can also use the not operator:

    <c:if test="${not theBooleanVariable}">It's false!</c:if>
    
    0 讨论(0)
  • 2020-12-01 00:19

    Both works. Instead of == you can write eq

    0 讨论(0)
  • 2020-12-01 00:23

    You can check this way too

    <c:if test="${theBooleanVariable ne true}">It's false!</c:if>
    
    0 讨论(0)
提交回复
热议问题