2015-04-21 33 views
0

是否有任何Groovy方法將List轉換爲字符串與值從消息屬性取代?Groovy - 列表到字符串與message.properties

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

list輸出數據,而我想從message.properties採取code需求爲逗號通過迭代列表分離

顯然,我能做到這一點,像這樣

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

回答

2

這裏沒有捷徑。你可以在你的視圖中使用這個:

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

這很棒... –