1 controller.java
List<String> ths = new ArrayList<String>(); // ths = [鼠疫, 霍乱]--列名
List<String> tds = new ArrayList<String>();
// tds = [101, 102]--列名对应的代码
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
// list = [{ORGAN_CODE=8651, 101=0, 102=0},
{ORGAN_CODE=8652, 101=1, 102=3},
{ORGAN_CODE=8653, 101=0, 102=0},
{ORGAN_CODE=8665, 101=0, 102=0},
{ORGAN_CODE=8606, 101=0, 102=0},
{ORGAN_CODE=8667, 101=0, 102=0},
{ORGAN_CODE=8668, 101=0, 102=2},
{ORGAN_CODE=8630, 101=0, 102=0}]
(列对应的值,以列code为key)
2 a.jsp
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%-- 计算共${(fn:length(ths)) +1}--%>
<table>
<colgroup>
<col style="width: 30px;min-width:30px;" /><%-- 机构列:列比较宽,单独处理 --%>
<c:forEach var="th" items="${ths}" varStatus="status">
<%-- 循环列宽 --%>
<col style="width: 10px;min-width:10px;" />
</c:forEach>
</colgroup>
<thead>
<tr>
<th colspan="${(fn:length(ths)) +1}">****报表 </th><%-- 合并标题行:机构单列+动态列
=${(fn:length(ths)) +1}--%>
</tr>
<tr>
<th >上报机构</th> <%--
机构列单独处理列名(固定列)
--%>
<c:forEach var="th" items="${ths}" varStatus="status">
<%-- 循环动态列名 --%>
<th>${th}</th>
</c:forEach>
</tr>
</thead>
</table>
<table>
<colgroup>
<col style="width: 30px;min-width:30px;" /><%-- 机构列:列比较宽,单独处理 --%>
<c:forEach var="th" items="${ths}" varStatus="status">
<col style="width: 10px;min-width:10px;" /><%-- 循环列宽 --%>
</c:forEach>
</colgroup>
<tbody>
<c:forEach var="result" items="${results}" varStatus="status">
<tr>
<%-- 机构列数据显示--%>
<td><ehr:org code="${result.ORGAN_CODE}"/></td>
<%-- 动态列数据显示 --%>
<c:forEach var="td" items="${tds}" varStatus="status">
<td>${result[td]}</td>
<%-- 例子:result.鼠疫 类似
result.ORGAN_CODE,但格式为result[td]--%>
</c:forEach>
</tr>
</c:forEach>
</tbody>
</table>

5651

被折叠的 条评论
为什么被折叠?



