在EL表达式中使用多个布尔条件

编程入门 行业动态 更新时间:2024-10-14 06:24:32
本文介绍了在EL表达式中使用多个布尔条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道如何在EL中组合多个布尔条件. 我有以下示例,但它不起作用.

I would like to know how can I combine multiple boolean coniditions in EL. I have following example and it is not working.

<x:someComponent rendered="#{bean.condition1} or #{bean.condition2}">

如何在EL中使用或"和与"逻辑运算符?

How can I use "OR" and "AND" logical operators in EL?

推荐答案

运算符必须放在EL表达式内部,而不是外部.您应该将#{...}视为一个大范围,其中各种变量/条件相互影响.

The operator has to go inside the EL expression, not outside. You should see the #{...} as one big scope wherein various variables/conditions interact with each other.

<x:someComponent rendered="#{bean.condition1 or bean.condition2}">

另请参见:

  • 我们的EL Wiki页面
  • 有条件地显示JSF组件
  • 如何有条件地呈现纯HTML元素,例如< div> ; s?
  • See also:

    • Our EL wiki page
    • Conditionally displaying JSF components
    • How to conditionally render plain HTML elements like <div>s?

更多推荐

在EL表达式中使用多个布尔条件

本文发布于:2023-11-22 14:38:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1617837.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   布尔   表达式   条件   EL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!