一尘不染

Concat JSF EL表达式中的两个String

java

我有以下el表达式:

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

但是我越来越

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

如何加入字符串?


阅读 238

收藏
2020-12-03

共1个答案

一尘不染

您可以使用 String.concat 函数:

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

2020-12-03