html - <th> 标记的位置无效

标签 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>

编辑:感谢您的快速回答

最佳答案

添加<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>

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

关于html - <th> 标记的位置无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35414379/

相关文章:

java - 仅重定向 HTML 页面一次

javascript - Bootstrap 4 模式不会关闭

javascript - 如何申请SameSite?

javascript - 用 替换空格会导致 â 字符不可见

html - div高度:100% and display:flex not working in Chrome

html - 如何将模型中的 HTML 显示为 HTML,而不是纯文本

html - 如何将一组广泛的样式应用(或编辑)到一个类/ID?

jquery - 如何使用jquery根据屏幕宽度添加css

javascript:使用正则表达式匹配并替换文本区域中的非标记 URL

html - 使用 rem 的 Chrome 和 Firefox 之间的字体大小差异