【发布时间】:2023-03-26 01:39:01
【问题描述】:
我想从循环中读取list 的键和值。
下面是我尝试过的代码 sn-p 但它不起作用。
<c:forEach items="${mylist}" var="title">
<c:set var="id" value="${title.key.id}"/>
<%Integer idInt = (Integer)pageContext.getAttribute("id");
String idStr = "";
if(idInt != null && idInt.intValue() > 0){
idStr = idInt.toString();
}%>
<s:radio theme="simple" name="selectedOption" list="#{idStr:title.value}"/>
</c:forEach>
【问题讨论】:
-
为什么是 sriplets?为什么
forEach?想做什么? -
@AleksandrM:我正在尝试从循环中读取列表的键和值。
-
列表的键?你是说索引吗?
-
@AleksandrM 是索引(listkey)和值
-
那么
title.key.id是什么?
标签: struts2 radio-button jstl struts ognl