I am iterating a java list in freemarker , but I want commas in between the words. Here's my code
<#list key_list[key] as value >${value?js_string}, </#list>
This gives me output as
a,b,c,d,
I want the output in this format:(No comma in the end)
a,b,c,d
How can I get that
You have to include an <#if value_has_next>,</#if>
statement.
This may help:
<#assign seq = ["winter", "spring", "summer", "autumn"]>
<#list seq as x>
${x_index + 1}. ${x}<#if x_has_next>,</#if>
</#list>
will output:
See this and more examples at: