EL 表达式中的 OR 条件如何发挥作用?
我想在此菜单中创建一个 OR 条件:
<li class="#{facesContext.viewRoot.viewId == ('/company/team.xhtml' or '/company/partnerships.xhtml' ) ? 'active' : '' }"><a class="item" href="company/company.xhtml">Company</a>
<ul>
<li><a href="company/team.xhtml">Team</a></li>
<li><a href="company/partnerships.xhtml">Partnerships</a></li>
</ul>
</li>
如果用户选择了 team.xthml 或partnerships.xhtml 页面,则将设置“active”值它位于
标记中。I would like to make an OR condition in this menu :
<li class="#{facesContext.viewRoot.viewId == ('/company/team.xhtml' or '/company/partnerships.xhtml' ) ? 'active' : '' }"><a class="item" href="company/company.xhtml">Company</a>
<ul>
<li><a href="company/team.xhtml">Team</a></li>
<li><a href="company/partnerships.xhtml">Partnerships</a></li>
</ul>
</li>
That if the team.xthml
or partnerships.xhtml
page are selected by the user the 'active' value would be set it in the <li>
tag.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是正确的语法:
要使其更短,您可以使用
#{view}
而不是#{facesContext.viewRoot}
:要使其更短,您可以将
#{view.viewId}
别名为
:This is the proper syntax:
To make it a bit shorter, you could use
#{view}
instead of#{facesContext.viewRoot}
:To make it yet shorter, you could alias the
#{view.viewId}
with<c:set>
: