1
獲取bean類中的值。 從bean類獲得的值將是java.util.Map。在通過下面的代碼得到的值是成功:JSTL使用JSTL從迭代映射
<c:forEach items="${bean.map}" var="item">
<c:out value="${item.key}"/> = <c:out value="${item.value}"/><br/>
</c:forEach>
獲得鍵值對後,我需要創建一個表4行7列。 地圖:
map.put(2, true);
map.put(18, true);
在地圖的關鍵是從1-28的和值將是TRUE或FALSE。
如果鍵值爲2且值爲TRUE,則在表格的(1,2)中放置複選標記,例如:第1行第2列。同樣,如果鍵爲18,則需要在表格(3,4)中放置一個複選標記。
<table border="1" width="100%">
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th>7</th>
</tr>
<c:forEach items="${bean.map}" var="item" >
<tr>
<td><c:out value="${item.value}"/></td>
</tr>
</c:forEach>
</table>
我不知道如何繼續下去,因爲我只限於使用JSTL,並且是JSTL的新手。我不允許使用javascript或jquery,這使得生活變得輕鬆。
請給我一些建議繼續下去。任何幫助將是可觀的。