SpringBoot整合JDBC把数据库中的数据显示到前端,为啥页面上除了出现数据库中的数据,还出现好多个 1 ,每一个1 代表一个数据库中的数据,这些1 应该怎样去除呢?

SpringBoot整合JDBC把数据库中的数据显示到前端,为啥页面上除了出现数据库中的数据,还出现好多个 1 ,每一个1 代表一个数据库中的数据,这些1 应该怎样去除呢?

问题描述:

1 在页面上显示的位置,但是我在我写的代码中并没有发现有这个1

img

在浏览器上直接检查,发现 出现 1 的位置

img

这一块前端对应的代码

<div class="row">
        <div class="col-lg-12">
            <table class="table">
                <thead>
                    <tr>
                        <th>用户Id</th>
                        <th>用户名</th>
                        <th>用户密码</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr th:each="user:${userList}">
                        <td th:text="${user.getId()}"></td>
                        <td th:text="${user.getName()}"></td>1
                        <td th:text="${user.getPwd()}"></td>
                        <td>

                            <a class="btn btn-primary" th:href="@{'/update/'+${user.getId()}}" >修改</a>
                            |
                            <a class="btn btn-success" th:href="@{'/del/'+${user.getId()}}">删除</a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>



<td th:text="${user.getName()}"></td>1

表格里面多了一个1,删除即可。

img

1是你页面中的数据,不是接口返回的。

<td th:text="${user.getName()}"></td>1
这个td后面多的1
<div class="row">
        <div class="col-lg-12">
            <table class="table">
                <thead>
                    <tr>
                        <th>用户Id</th>
                        <th>用户名</th>
                        <th>用户密码</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr th:each="user:${userList}">
                        <td th:text="${user.getId()}"></td>
                        <td th:text="${user.getName()}"></td>
                        <td th:text="${user.getPwd()}"></td>
                        <td>
                            <a class="btn btn-primary" th:href="@{'/update/'+${user.getId()}}" >修改</a>
                            |
                            <a class="btn btn-success" th:href="@{'/del/'+${user.getId()}}">删除</a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>