Using && in EL results in error: The entity name must immediately follow the '&' in the entity reference

佐手、 提交于 2019-12-03 06:05:25

You seem to be using Facelets (which is perfectly fine). It's however a XML based view technology. Everything which you write in Facelets has to be syntactically valid XML. The & is in XML a special character denoting the start of an entity like &, <, >,  , etc.

If you would like to represent the & as-is in XML, then you'd have to replace it by &.

<h:outputText value="#{(sel.description !=null) &amp;&amp; (sel.description !='') ? sel.description : 'Empty description'} - "/>

However, that's not pretty readable, you would rather like to use the alternative EL operator and for this (see also operators in EL for an overview of all available operators in EL):

<h:outputText value="#{(sel.description !=null) and (sel.description !='') ? sel.description : 'Empty description'} - "/>

All with all, this is in turn pretty clumsy as there's a simpler empty keyword for the purpose of testing both nullness and emptiness. This can in your particular case be used as:

<h:outputText value="#{not empty sel.description ? sel.description : 'Empty description'} - "/>

or

<h:outputText value="#{!empty sel.description ? sel.description : 'Empty description'} - "/>

or

<h:outputText value="#{empty sel.description ? 'Empty description' sel.description} - "/>

Use and instead of &&. You simply have XML syntax error.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!