我刚刚开始学习JSTL,所以我可能会遗漏一些明显的东西,但是如何循环遍历ArrayList .get()方法的列表。我需要迭代使用一个计数器,即.get(i)。
JSP代码:
<c:forEach items="${processVariablesList}" var="customerHistoryVariables">
<c:forEach items="${processVariablesList.get(0)}" var="variable">
<li><strong>${variable.getName()}: </strong>${variable.getValue()}</li>
</c:forEach>
</c:forEach>
Servlet代码:
ArrayList<List<HistoricVariableInstance>> processVariablesList = new ArrayList<List<HistoricVariableInstance>>();
for(int i = 0;i<processList.size();i++){
String processId = processList.get(i).getId();
List<HistoricVariableInstance> variableList = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(processId).list();
processVariablesList.add(variableList);
}
答案 0 :(得分:3)
Ty this:
<c:forEach items="${processVariablesList}" var="customerHistoryVariables">
<c:forEach items="${customerHistoryVariables}" var="variable">
<li><strong>${variable.getName()}: </strong>${variable.getValue()}</li>
</c:forEach>
</c:forEach>