[英]How to iterate through a hashmap with value as an arraylist for a given index
我在以下代码中保存了一个哈希表,其中Integer作为键,而ArrayList作为值
<c:set var="form" value="${surveyQuestionnaire}"/>
<c:forEach var="questionName" items="${form.questionsList }" varStatus="theCount">
Q.<c:out value="${questionName}"></c:out>
<c:forEach items="${savedQuestionAnswer[(theCount.count).longValue()]}" var="choice" varStatus="choiceStatus">
<br/> ${choiceStatus.count})${choice}
</c:forEach> <br/>
</c:forEach>
我正在尝试打印具有多个答案的问卷。 因此,对于每个问题(在questionName中存在),我都将答案列表保存在哈希表savedQuestionAnswer
并带有相应的索引值。
我收到语法错误,
“未指定默认名称空间时,必须将函数longValue与前缀一起使用”。
无法获得正确的语法或完成方法
LoopTagStatus.getCount()返回int。 为什么你需要:
${savedQuestionAnswer[(theCount.count).longValue()]}
简单尝试
${savedQuestionAnswer[theCount.count]}
另请注意
因此,根据您填充HashMap的方式,应使用
theCount.index
要么
theCount.count
作为关键。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.