I have a list of strings - which are the properties names that I am interested in:
I want to join the values of these strings, but not using the properties name, but the properties values for them.
I saw that the starting point is #strings.listJoin
- but how can I say to match the elements in the list against their value in the properties files?
The list would be: [name, address]
and in the properties file I have:
name=stg
address=another something
I would like to obtain the string: stg, another something
You can do it by utilizing #messages.listMsg
and #strings.listJoin
Having the model returned from your @Controller:
model.addAttribute("messageKeyList", Lists.newArrayList("name", "address"));
You can join list of translated messages like this:
<div th:text="${#strings.listJoin(#messages.listMsg(messageKeyList), ',')}"></div>
Which should produce what you expect, e.g.:
Some name,Some address
Where name and address are keys in your messages file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With