我想在Velocity模板内创建一个表,该模板从
Map<String, List<String>>
foreach
循环,但由于某些原因,它不起作用(即使有数据也为空表)。
将数据添加到我的模型中
model.put("downloaded", holder.getDownloadedFiles());
这将添加如上所述的地图。
我的模板:
<table >
<tr>
<th style="width:150px">Subsystem</th>
<th style="width:500px">Filename</th>
</tr>
#foreach( $system in $downloaded.keySet)
#foreach($file in ${downloaded.get($system)})
<tr>
#if($foreach.count == 1) ##do only once
<td rowspan=$downloaded.get($system).size()>$system</td>
#end
<td>$file</td>
</tr>
#end
#end
</table>
key value1
value2
value3
value4
key2 value1
value2
value3
value4
我是否正确访问变量并正确调用方法?