实验目的:掌握基于SpringBoot的CRUD增删改查操作。
实验步骤:
1、SpringBoot系列教材 (一)- 基础 - Springboot入门-在Eclipse中创建跑得起来的springboot项目,非STS插件方式
2、SpringBoot系列教材 (十四)- 持久层支持 - Springboot中如何运用Mybatis 简单例子
3、SpringBoot系列教材 (十五)- 持久层支持 - Mybatis-xml方式
4、SpringBoot系列教材 (十七)- CRUD+分页 - Springboot使用Mybatis实现完整的 增删改查 CRUD和分页
5、在上述操作理解和熟练的基础上,对Product表和Users表进行CRUD增删改查的操作。
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<table>
<tr>
<th colspan="4">用户列表</th>
</tr>
<tr>
<td>用户id</td>
<td>用户名</td>
<td>用户账户</td>
<td>操作</td>
</tr>
<tr th:each="user:${page.list}">
<td th:text="${user.userId}"></td>
<td th:text="${user.username}"></td>
<td th:text="${user.balance}"></td>
<td>
<a href="/delete">删除</a>
<a href="/update">更新</a>
</td>
</tr>
</table>
<div>
<a th:if="${page.hasPreviousPage}" th:href="@{/page/1}">首页</a>
<a th:if="${page.hasPreviousPage}" th:href="@{'/page/' + ${page.prePage}}">上一页</a>
<span th:each="num : ${page.navigatepageNums}">
<a th:if="${page.pageNum == num}" style="color: red;" th:href="@{'/page/' + ${num}}" th:text="'[' + ${num} + ']'"></a>
<a th:if="${page.pageNum != num}" th:href="@{'/page/' + ${num}}" th:text="${num}"></a>
</span>
<a th:if="${page.hasNextPage}" th:href="@{'/page/' + ${page.nextPage}}">下一页</a>
<a th:if="${page.hasNextPage}" th:href="@{'/page/' + ${page.pages}}">尾页</a>
</div>
</body>
</html>