我正在寻找一种简洁的方法来将字符串重复 n 次,其中 n 是一个变量。我在 docs 中找不到这样做的好办法.
最佳答案
<#assign n = 5>
<#list 0..<n as i>hello</#list>
或者作为一个宏:
<#macro repeat input times>
<#list 0..<times as i>${input}</#list>
</#macro>
<@repeat input="hello" times=5/>
关于freemarker - 在 freemarker 中重复一个字符串 n 次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39264184/