SoFunction
Updated on 2025-04-05

Example code for dynamically merging cells in JSP

I won't say much nonsense, the specific code is as follows:

<span style="font-size:14px;"> 
<%@ taglib prefix="c" uri="/jsp/jstl/core"%> 
<table width="100%" border="0" cellspacing="0" cellpadding="0" > 
<tr> 
<th> 
Report name 
</th> 
</tr> 
<c:set var="tempCount" value="0"></c:set><%--Temporary variables --%> 
<c:set var="rowspanCount" value="0"></c:set><%--Record the number of merged columns --%> 
<c:set var="tempFrist" value="0"></c:set><%--Record the merge start position --%> 
<c:set var="tempEnd" value="-1"></c:set><%--Record merge end position --%> 
<c:forEach items="${list}" var="accountConfig" varStatus="status" > 
<tr> 
<%--Using a result setList<Bean>To generate,Too much data will increase customer interruption burden --%> 
<c:if test="${>=tempEnd}"> 
<c:set var="rowspanCount" value="0"></c:set><%--Clear historical data --%> 
<c:forEach var="item2" items="${list}" varStatus="status2"> 
<%-- tablenameRefers to the attribute to be merged --%> 
<c:if test="${==}"> 
<c:set var="tempFrist" value="${ }"></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="${==tempFrist}"> 
<td rowspan="${rowspanCount}"> 
<%-- tablenameRefers to the attribute to be merged --%> 
${} 
</td> 
</c:if> 
</tr> 
</c:forEach> 
</table> 
</span> 

The above is the example code for dynamically merging cells in JSP introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!