How to process and join string in thymeleaf

前端 未结 1 1733
夕颜
夕颜 2021-01-18 05:55

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 pro

相关标签:
1条回答
  • 2021-01-18 06:36

    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.

    0 讨论(0)
提交回复
热议问题