messages.properties键,多个点不起作用

问题描述 投票:1回答:1

我正在为.xhtml页面使用messages.properties包。我可以访问密钥并使用它们,如果他们有一个名称。链接同一类别的密钥并将它们除以.会导致问题。

EG mesages.propertis:

bookTitle=Title

我像这样加载我的包:

<f:loadBundle var="msg" basename="messages"/>

并像这样使用bundle:

<p:column headerText="#{msg.bookTitle}" filterBy="#{row.book.title}" filterMatchMode="contains">
    <h:outputText value="#{row.book.title}" />
</p:column>

这项工作非常好。

问题:

使用:

book.title=Title
book.url=URL

我无法使用#{msg.book.title}访问值并收到以下错误消息:

headerText="#{msg.book.title}": Property [title] not found on type [java.lang.String]

我正在使用Lombok来生成getter和setter。我担心问题是第一个密钥book被检索为一个字符串,然后lombok尝试在String对象(书)上使用getTitle()方法,从而引发异常

java spring properties-file
1个回答
1
投票

使用

#{msg['book.title']}

代替。那应该是它。 这是一种语法,imho应仅用于具有点作为名称一部分的键。

顺便说一句,龙目岛没有参与其中。

© www.soinside.com 2019 - 2024. All rights reserved.