我有一个字符串列表 - 这是我感兴趣的属性名称:
我想连接这些字符串的值,但不使用属性名称,而是使用它们的属性值。
我看到起点是#strings.listJoin
- 但是我怎么能说将列表中的元素与属性文件中的值相匹配呢?
该列表将是:[name, address]
在属性文件中我有:
name=stg
address=another something
I would like to obtain the string:
stg, another something
你可以通过利用来做到这一点#messages.listMsg
and #strings.listJoin
从 @Controller 返回模型:
model.addAttribute("messageKeyList", Lists.newArrayList("name", "address"));
您可以像这样加入翻译消息列表:
<div th:text="${#strings.listJoin(#messages.listMsg(messageKeyList), ',')}"></div>
这应该会产生您所期望的结果,例如:
Some name,Some address
其中姓名和地址是消息文件中的键。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)