我有一些数据,我想要显示它。 telnumbers
和'teltype`必须位于其所有者的一列中。如何正确显示表格?
我有这样的:
,这我的代码:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:spring="http://www.springframework.org/tags"
version="2.0">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<jsp:output omit-xml-declaration="yes"/>
<style>
table, th, td {
border: 1px solid black;
}
</style>
<h1>Contact list</h1>
<c:if test="${not empty contacts}">
<table>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Birth Date</th>
<th>tel_type</th>
<th>tel_number</th>
<th>hobby</th>
</tr>
</thead>
<tbody>
<c:forEach items="${contacts}" var="contact">
<jsp:useBean id="contact" scope="page" type="org.training.support.model.Contact"/>
<tr>
<td>"${contact.firstName}"</td>
<td>"${contact.lastName}"</td>
<td>"${contact.birthDate}"</td>
<c:forEach items="${contact.contactDetails}" var="telDetail">
<jsp:useBean id="telDetail" scope="page" type="org.training.support.model.ContactTelDetail"/>
<td>"${telDetail.telNumber}"</td>
<td>"${telDetail.telType}"</td>
</c:forEach>
<c:forEach items="${contact.hobbies}" var="hobby">
<jsp:useBean id="hobby" scope="page" type="org.training.support.model.Hobby"/>
<td>"${hobby.id}"</td>
</c:forEach>
</tr>
</c:forEach>
</tbody>
</table>
</c:if>
</div>
请不要为每个数据使用TD。使用一些分隔符代替使用2 td – 2017-05-08 03:15:55
我认为这会帮助你。检查“跨越两列的单元格”。 https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_span。如果没有帮助,请再次提问 – 2017-05-08 03:55:13
对不起,但我不知道,我怎么可以让我的例子随机colspan(这个很好的例子,但在我的情况下,它不工作,导致contact.contactDetails.size()未定义(随机)( –