【发布时间】:2020-09-19 16:39:29
【问题描述】:
JSP 代码:
<c:forEach var="map" items="${map}">
<tr>
<td>
<table border="1">
<tr class="header expand">
<th>${map.key.id}</th><th>${map.key.name}</th><th>${map.key.status}<span class="sign"></span></th>
</tr>
</table>
</td>
<td>
<table border="1">
<tr>
<th>REQUEST_ID</th>
<th>LOGIN_USER</th>
<th>PRICE</th>
<th>STATUS</th>
</tr>
<c:forEach var="item" items="${map.value}">
<tr>
<td>${item.REQUEST_ID}</td><td>${item.LOGIN_USER}</td><td>${item.PRICE}</td><td>${item.STATUS}</td>
</tr>
</c:forEach>
</table>
</td>
</tr>
</c:forEach>
折叠表代码:
<style type="text/css">
table, tr, td, th
{
border: 1px solid black;
border-collapse:collapse;
}
tr.header
{
cursor:pointer;
}
.header .sign:after{
content:"+";
display:inline-block;
}
.header.expand .sign:after{
content:"-";
}
</style>
<body>
<table border="0">
<tr class="header expand">
<th colspan="2">Header <span class="sign"></span></th>
</tr>
<tr>
<td>data</td>
<td>data</td>
</tr>
<tr>
<td>data</td>
<td>data</td>
</tr>
</table>
<script type="text/javascript">
$('.header').click(function(){
$(this).toggleClass('expand').nextUntil('tr.header').slideToggle(100);
});
</script>
</body>
我有一张正在 JSP 中检索的地图。它有对象作为键,arraylist 作为值。arraylist 由作为对象的行组成。对于具有唯一 reqid 的特定键,它具有特定于 reqid 的所有行作为 arraylist 中的对象。我想在 JSP 中检索它。它必须是可折叠的表格,键是我的标题和值,即与 reqid 相关的行必须出现在该标题下。我有独立的 JavaScript 代码来实现它。我尝试在 JSP 中添加,但浏览器没有结果.我需要帮助在 JSP 代码中设计可折叠表格。
预期输出:
123 A 1 ///Table header
123 A 5 2
123 A 10 3
//N no of rows
456 B 2 ///Table header
456 B 20 3
456 B 25 2
//N no of rows
【问题讨论】:
标签: javascript java jquery jsp hashmap