String contains method in jsf

2019-02-12 08:42发布

问题:

i was wondering how to use/implement string contains method in jsf2 without using JSTL. please advise, thanks.

回答1:

<h:outputText value="#{'I love JSF'.contains('JSF')}" /> <!-- true -->

OR

<h:outputText value="#{myBean.text.contains('some_word')}" />


回答2:

In addition you can use JSTL functions

Add this:

xmlns:fn="http://java.sun.com/jsp/jstl/functions"

And use it like this

render="#{fn:contains(myBean.myText, 'test')}"


标签: jsf jsf-2 el