标签的位置无效

时间:2016-02-15 16:31:22

标签: html

这是一个简单的jsp页面的html,所有<th>标签都是无效的位置。我正在按照我正在尝试的同类型项目的指南进行操作,这也是指南的原因......

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Doctors</title>
</head>
<body>
<div align="center">
    <h1>Doctor List</h1>
    <h3><a href="newDoctor">New Doctor</a></h3>
    <table border="1">
        <th>Id</th>
        <th>Name</th>
        <th>Email</th>
        <th>Medical Degree</th>
        <th>Education</th>
        <th>Action</th>


        <c:forEach var="doctor" items="${doctors}">
        <tr>
            <td>${doctor.id}</td>
            <td>${doctor.lastName}, ${doctor.firstName}</td>
            <td>${doctor.email}</td>
            <td>${doctor.degree}</td>
            <td>${doctor.education}</td>
            <td>
                <a href="editDoctor?id=${doctor.id}">Edit</a>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <a href="deleteDoctor?id=${doctor.id}">Delete</a>
            </td>

        </tr>
        </c:forEach>             
    </table>
</div>
</body>
</html>

编辑:感谢您的快速回答

2 个答案:

答案 0 :(得分:3)

添加<tr>代码并将所有<th>放在其中。

喜欢这个:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Doctors</title>
</head>
<body>
<div align="center">
    <h1>Doctor List</h1>
    <h3><a href="newDoctor">New Doctor</a></h3>
    <table border="1">
        <tr>
           <th>Id</th>
           <th>Name</th>
           <th>Email</th>
           <th>Medical Degree</th>
           <th>Education</th>
           <th>Action</th>
        </tr>    

        <c:forEach var="doctor" items="${doctors}">
        <tr>
            <td>${doctor.id}</td>
            <td>${doctor.lastName}, ${doctor.firstName}</td>
            <td>${doctor.email}</td>
            <td>${doctor.degree}</td>
            <td>${doctor.education}</td>
            <td>
                <a href="editDoctor?id=${doctor.id}">Edit</a>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <a href="deleteDoctor?id=${doctor.id}">Delete</a>
            </td>

        </tr>
        </c:forEach>             
    </table>
</div>

我希望这能解决这个问题。

答案 1 :(得分:2)

看起来您只需要一些表格行,但为了安全起见,我们可以添加tbodythead

<table>
    <thead>
        <th>Id</th>
        <th>Name</>
        <th>Email</th>
        <th>Medical Degree</th>
        <th>Education</th>
        <th>Action</th>
    </thead>
    <tbody>
        <c:forEach var="doctor" items="${doctors}">
            <tr>
                <td>${doctor.id}</td>
                <td>${doctor.lastName}, ${doctor.firstName}</td>
                <td>${doctor.email}</td>
                <td>${doctor.degree}</td>
                <td>${doctor.education}</td>
                <td>
                    <a href="editDoctor?id=${doctor.id}">Edit</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="deleteDoctor?id=${doctor.id}">Delete</a>;
                </td>
            </tr>
        </c:forEach>
    </tbody>
</table>