js解析后端传来的如图示的list集合,怎么获取每个map的key和value
如图示,后端传到前端的questTypeList是一个HashMap的list集合
使用c标签将传来的集合放到下拉单选框中,
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<form action="yourAction" method="post">
<label for="optionSelect">请选择选项:</label>
<select id="optionSelect" name="selectedOption">
<!-- 使用 c:forEach 遍历集合并填充下拉框 -->
<c:forEach var="item" items="${questTypeList}">
<c:forEach var="entry" items="${item}">
<option value="${entry.key}">${entry.value}</option>
</c:forEach>
</c:forEach>
</select>
<input type="submit" value="提交" />
</form>
</body>
</html>
注意,是两个forEach循环!!!!!!! 使用c标签要引入
<%@ taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core” %>