Concat在JSF EL表达式中的两个字符串

时间:2013-06-14 06:46:06

标签: java string jsf el concat

我有以下表达式:

<af:outputText value="#{viewArticle.publish ? ('Publish on ' + viewArticle.publishDate + ' by ' + viewArticle.publishFirstName + ' ' + viewArticle.publishLastName) : 'Draft version'}"/>

但我得到了

java.lang.NumberFormatException: For input string: "Publish on "

我如何加入字符串?

3 个答案:

答案 0 :(得分:62)

您可以使用 String.concat 功能:

<af:outputText value="#{viewArticle.publish ? 'Publish on '.concat(viewArticle.publishDate).concat(' by ').concat(viewArticle.publishFirstName).concat(' ').concat(viewArticle.publishLastName) : 'Draft version'}"/>

答案 1 :(得分:31)

你应该写

value  = "#{someBean.aProperty}  something you want in between #{someBean.anotherProperty}"

答案 2 :(得分:4)

您必须编写自定义EL功能。 This example会帮助你:)