Instance code for dynamically merging cells in JSP

  • 2021-11-24 02:32:41
  • OfStack

No more nonsense, the specific code is as follows:

<span style="font-size:14px;"> 
<%@ taglib prefix="c" uri=""%> 
<table width="100%" border="0" cellspacing="0" cellpadding="0" > 
 Report name  
<c:set var="tempCount" value="0"></c:set><%-- Temporary variable  --%> 
<c:set var="rowspanCount" value="0"></c:set><%-- Number of record merged columns  --%> 
<c:set var="tempFrist" value="0"></c:set><%-- Record merge start position  --%> 
<c:set var="tempEnd" value="-1"></c:set><%-- Record merge end position  --%> 
<c:forEach items="${list}" var="accountConfig" varStatus="status" > 
<%-- Utilization 1 Result sets List<Bean> To generate, too much data will increase the burden on customers  --%> 
<c:if test="${status.index>=tempEnd}"> 
<c:set var="rowspanCount" value="0"></c:set><%-- Clear historical data  --%> 
<c:forEach var="item2" items="${list}" varStatus="status2"> 
<%-- tablename Refers to the attributes to be merged  --%> 
<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 test="${status.index==tempFrist}"> 
<td rowspan="${rowspanCount}"> 
<%-- tablename Refers to the attributes to be merged  --%> 

Related articles: