Java 填充Freemarker模板上的组合框
我试图在组合框中加载数据,该组合框存储在名为Java 填充Freemarker模板上的组合框,java,html,combobox,freemarker,Java,Html,Combobox,Freemarker,我试图在组合框中加载数据,该组合框存储在名为列的列表中 这是我在模板上的费用数据代码: List<ArrayList<String>> columna = con.getColumn("table", "column"); Iterator<ArrayList<String>> iter = columna.iterator(); String name= null; while (iter.hasNext()) { ArrayList&l
列的列表中
这是我在模板上的费用数据代码:
List<ArrayList<String>> columna = con.getColumn("table", "column");
Iterator<ArrayList<String>> iter = columna.iterator();
String name= null;
while (iter.hasNext()) {
ArrayList<String> row = iter.next();
for(int i=0; i<row.size(); i++) {
name=row.get(i);
attributes.put("tmplattribute", name); //There are my problem I think
}
}
有没有办法用所有数据填充组合框?目前我只得到最后一行,因为“attributes”参数是一个(键,值)数据,我只能为该键存储一个值。列表您可以查看freemarker文档。谢谢Daniel!你的回答告诉了我解决问题的方法
List<ArrayList<String>> columna = con.getColumn("table", "column");
attributes.put("mylist", columna);
如果我使用您的模板代码,我会从列表中为每个对象获得一个组合框,但如果我更改其顺序如下:
<select name="combo">
<#list mylist as it>
<#list it as tmplattribute>
<option value="${tmplattribute}">${tmplattribute}</option>
</#list>
</#list>
</select>
${tmplattribute}
我得到我需要的东西。再次感谢你,因为你的回答为我指明了方向
<#list mylist as it>
<select name="combo">
<#list it as tmplattribute>
<option value="${tmplattribute}">${tmplattribute}</option>
</#list>
</select>
</#list>
<select name="combo">
<#list mylist as it>
<#list it as tmplattribute>
<option value="${tmplattribute}">${tmplattribute}</option>
</#list>
</#list>
</select>