我试图在地图中添加序列作为值:
<#assign client_sequence=['a', 'b']>
{
clients: ${client_sequence},
usecase_key: usecase_value,
other_key: other_value
}
在上面的示例中,client_sequence将从另一个无法更改的模块传递。我已将其替换为说明。
我收到以下错误:
For "${...}" content: Expected a string or something automatically convertible to string (number, date or boolean), or "template output" , but this has evaluated to a sequence (wrapper: f.t.SimpleSequence):
==&GT; client_sequence [在第3行第16列的无名模板中]
FTL stack trace ("~" means nesting-related):
答案 0 :(得分:1)
使用内置逗号的FreeMarker序列join:
<#assign client_sequence=['a', 'b','c']>
{
clients: ${client_sequence?join(", ")}
usecase_key: usecase_value,
other_key: other_value
}
使用给定的分隔符将序列的项连接到单个字符串。