0
我在jsp頁面內部有html表格。我的代碼如下所示:如何在jsp頁面的html表格中重複使用相同的<tr>標記
<c:choose>
<c:when test="${empty institutionAttributes}">
<h2 align="center"><spring:message code="label.attributes.msg"/> </h2>
</c:when>
<c:otherwise>
<h3 align="center"><spring:message code="label.result.msg"/> </h3>
<table border="1" align="center">
<thead>
<tr>
<th align="center"><spring:message code="label.header.table.name" /></th>
<th align="center"><spring:message code="label.header.table.type" /></th>
<th align="center"><spring:message code="label.header.table.date" /></th>
<th align="center"><spring:message code="label.header.table.dayscheduale" /></th>
<th align="center"><spring:message code="label.header.table.workscheduale" /></th>
<th align="center"><spring:message code="label.header.table.rotation" /></th>
<th align="center"><spring:message code="label.header.table.numberkids" /></th>
<th align="center"><spring:message code="label.header.table.under3" /></th>
<th align="center"><spring:message code="label.header.table.upper3" /></th>
<th align="center"><spring:message code="label.header.table.goschool" /> <br> <fmt:formatDate value="${formDescriptionVar.kidsGoSchoolDate}" pattern="yyyy"/> <spring:message code="label.header.table.year" /></th>
</tr>
</thead>
<tbody>
<c:forEach items="${institutionAttributes}" var="institutionVar">
<tr>
<td align="center">${institutionVar.nameOfInstitution}</td>
</tr>
</c:forEach>
<c:forEach items="${institutionTypeAttributes}" var="institutionTypeVar">
<tr>
<td align="center">${institutionTypeVar.typeOfInstitution}</td>
</tr>
</c:forEach>
<c:forEach items="${formDateAttributes}" var="formDateVar">
<tr>
<td align="center"><fmt:formatDate value="${formDateVar.particularDate}" pattern="dd-MM-yyyy"/> </td>
</tr>
</c:forEach>
<c:forEach items="${formDescriptionAttributes}" var="formDescriptionVar">
<tr>
<td align="center">${formDescriptionVar.daySchedule}</td>
<td align="center">${formDescriptionVar.workScheduale}</td>
<td align="center">${formDescriptionVar.rotation}</td>
<td align="center">${formDescriptionVar.numberOfKids}</td>
<td align="center">${formDescriptionVar.kidsUnder3YearsOld}</td>
<td align="center">${formDescriptionVar.kidsUpper3YearsOld}</td>
<td align="center">${formDescriptionVar.kidsGoSchoolNumber}</td>
</tr>
</c:forEach>
</tr>
</tbody>
</table>
</c:otherwise>
</c:choose>
內JSP頁面中我有<thead>
和<tbody>
標籤表。
<tbody>
我使用JSP的<c:forEach>
標籤。
<c:forEach>
我使用<tr>
和<td>
標籤。
在照片,我想:
|------------------------------------|
| Header1 | Header2 | Header3 |
|------------------------------------|
| Value1 | Value2 | Value3 |
|------------------------------------|
我能得到什麼:
|------------------------------------|
| Header1 | Header2 | Header3 |
|------------------------------------|
| Value1 | | |
|------------------------------------|
| | Value2 | |
|------------------------------------|
| | | Value3 |
|------------------------------------|
那麼,問題是,<c:forEach>
創造新<tr>
每<c:forEach>
裏面,但我需要的是使用相同<tr>
不同<c:forEach>
。我怎樣才能做到這一點?
是的,我很抱歉,我的問題是不夠清楚..我編輯它 –
@ user2547487,我仍然認爲你需要做的是我解釋的......你試過了嗎? – MikO
先生。它會在每一行中放置1,2,3的名稱,將其劃分爲新的一行。我不希望它是這樣的。我需要將nameofInstitution1和nameofInstitution2和nameofInstitution3放在一行中。就像在我上面的圖片中,我想要的... –