Spring boot CRUD

一、列表页   templates/emp/list.html

0、侧边栏链接:

<li class="nav-item">
    <a class="nav-link" href="#"  th:href="@{/emps}" th:class="${activeUrl == 'emps' ? 'nav-link active' : 'nav-link'}">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-users">
            <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
            <circle cx="9" cy="7" r="4"></circle>
            <path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
            <path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
        </svg>
        员工管理
    </a>
</li>

1、跳转映射请求

@GetMapping("/emp")
public String addEmpPage(Model model) {
    return "emp/add";
}

2、列表页面源码

<div th:replace="commons/bar :: topBar"></div>
        <div class="container-fluid">
            <div class="row">
                <div th:replace="commons/bar :: sideBar(activeUrl=emps)"></div>

                <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
                    <h2><a class="btn btn-sm btn-success" href="emp" th:href="@{/emp}">员工添加</a></h2>
                        <div class="table-responsive">
                        <table class="table table-striped table-sm">
                            <thead>
                                <tr>
                                    <th>id</th>
                                    <th>姓氏</th>
                                    <th>邮箱</th>
                                    
                                    <th>性别</th>
                                    <th>部门</th>
                                    <th>生日</th>
                                    
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr th:each="emp : ${emps}">
                                
                                    <td th:text="${emp.id}"></td>
                                    <td th:text="${emp.lastName}">Lorem</td>
                                    <td  th:text="${emp.email}">ipsum</td>
                                    
                                    <td th:text="${emp.gender}">dolor</td>
                                    <td th:text="${emp.department.departmentName}">sit</td>
                                    <td th:text="${emp.birth}">sit</td>
                                    
                                    <td>
                                        <button class="btn btn-sm btn-primary" type="submit">编辑</button>
                                        <button class="btn btn-sm btn-danger" type="submit">删除</button>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                </main>
            </div>
        </div>

 3、列表效果

猜你喜欢

转载自www.cnblogs.com/guchunchao/p/10008918.html