DataTables:未捕获的TypeError:无法读取属性' mData'未定义的

时间:2016-05-22 15:58:13

标签: javascript html twitter-bootstrap jsp datatables

我想在我的页面中使用DataTable显示表格:

<table id="example" class="display" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Username</th>
            <th>Firstname</th>
            <th>Lastname</th>
            <th>Phone</th>
            <th>Password</th>
            <th></th>
        </tr>
    </thead>
    <tfoot>
       <tr>
            <th>Username</th>
            <th>Firstname</th>
            <th>Lastname</th>
            <th>Phone</th>
            <th>Password</th>
            <th></th>
            <th></th>
        </tr>
    </tfoot>
    <tbody>
        <c:forEach items="${users}" var="user" varStatus="status">
            <tr>
                <form>
                    <td class="text-center">${user.getUsername()}</td>
                    <td class="text-center">${user.getFirstname()}</td>
                    <td class="text-center">${user.getLastname()}</td>
                    <td class="text-center">${user.getPhone()}</td>
                    <td class="text-center">${user.getPassword()}</td>
                </form>
                <td class="text-center"><button class="btn btn-user"   onclick="show('block','${user.getUsername()}')">Delete</button></td>
                <td class="text-center"><button class="btn btn-user" onclick="show2('block','${user.getFirstname()}','${user.getLastname()}','${user.getUsername()}', '${user.getPhone()}','${user.getPassword()}')">Edit</button></td>
            </tr>
      </c:forEach>
    </tbody>
</table>

但我得到错误:未捕获的TypeError:无法读取属性&#39; mData&#39;未定义的

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我解决了我的问题:<th></th>

中缺少<thead>