gpt4 book ai didi

grails - Groovy-使用message.properties列出到字符串

转载 作者:行者123 更新时间:2023-12-02 15:05:56 25 4
gpt4 key购买 nike

是否有任何Groovy方法将List转换为String,并使用消息属性中替换的值?

<g:message code="label.promotion.create.short.${command.daysList.join(",")}"/>

来自 list的哪个输出数据,而不是我希望 code需要从message.properties中获取,以逗号分隔

显然,我可以通过迭代列表来做到这一点,就像这样
<g:each in="${command.daysList}" var="day" status="count">
<g:message code="label.promotion.create.short.${day}"/>
<g:if test="${count+1 < command.daysList.size()}">, </g:if>
</g:each>

最佳答案

没有捷径可走。您可以在自己的 View 中使用它:

command.dayList.collect{ message(code: "label...${it}") }.join(", ")

关于grails - Groovy-使用message.properties列出到字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29769741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com