简体   繁体   English

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

[英]Groovy - list to String with message.properties

Is there any Groovy method which converts List to String with values substituted from message properties? 是否有任何Groovy方法将List转换为String,并使用消息属性中替换的值?

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

Which output data from the list , rather I want code needs to be taken from message.properties as comma separated list哪些输出数据,而不是我希望code需要从message.properties中以逗号分隔

Obviously I can do it through iterating the list, like this 显然,我可以通过迭代列表来做到这一点,就像这样

<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>

there is no shortcut for this. 没有捷径可走。 you can use this in your view: 您可以在自己的视图中使用它:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM