Home > Web Front-end > JS Tutorial > Example code for dynamically merging cells in JSP

Example code for dynamically merging cells in JSP

高洛峰
Release: 2016-12-29 16:04:14
Original
1706 people have browsed it

No more nonsense, the specific code is as follows:

<span style="font-size:14px;"> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<table width="100%" border="0" cellspacing="0" cellpadding="0" > 
<tr> 
<th> 
报表名称 
</th> 
</tr> 
<c:set var="tempCount" value="0"></c:set><%--临时变量 --%> 
<c:set var="rowspanCount" value="0"></c:set><%--记录合并列数 --%> 
<c:set var="tempFrist" value="0"></c:set><%--记录合并开始位置 --%> 
<c:set var="tempEnd" value="-1"></c:set><%--记录合并结束位置 --%> 
<c:forEach items="${list}" var="accountConfig" varStatus="status" > 
<tr> 
<%--利用一个结果集List<Bean>来生成,数据过多会加重客户断负担 --%> 
<c:if test="${status.index>=tempEnd}"> 
<c:set var="rowspanCount" value="0"></c:set><%--清楚历史数据 --%> 
<c:forEach var="item2" items="${list}" varStatus="status2"> 
<%-- tablename指要合并的属性 --%> 
<c:if test="${accountConfig.tablename==item2.tablename}"> 
<c:set var="tempFrist" value="${status.index }"></c:set> 
<c:set var="rowspanCount" value="${rowspanCount+1 }"></c:set> 
<c:set var="tempEnd" value="${tempFrist+rowspanCount }"></c:set> 
</c:if> 
</c:forEach> 
</c:if> 
<c:if test="${status.index==tempFrist}"> 
<td rowspan="${rowspanCount}"> 
<%-- tablename指要合并的属性 --%> 
${accountConfig.tablename} 
</td> 
</c:if> 
</tr> 
</c:forEach> 
</table> 
</span>
Copy after login

The above is the example code of dynamically merging cells in JSP introduced by the editor. I hope it will be helpful to everyone. If If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!

For more related articles on the example code of dynamically merging cells in JSP, please pay attention to the PHP Chinese website!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template