1.实现分页功能:
首先要分析页面的https://elasticsearch.cn/explore/ 分页特点,当前页不是第一页时,“<”就会出现,与之对应的,当当前页不是最后一页时,“>”就会出现;另外页面是以7个数字为一组,当这7个数字不包含首页时,“<<”就会出现,而不包含尾页时,“>>”就会出现。
select * from question limit a, b: 从a位置开始,返回b个数据
select * from question limit a offset b:从b位置开始返回a个数据
2.P27:引入jquery后还显示404错误
解决方法:引入资源的顺序问题,必须先引入jquery,后引入bootstrap.min.js,因为在bootstrap.min.js有对jquery的使用。
3.thymeleaf:将固定的样式进行封装,在不同的页面进行调用。
navigation.html:存放格式的页面
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div th:fragment="nav">
//放固定的格式
</div>
</body>
</html>
进行调用
<div th:insert="navigation :: nav"></div>
4.@PathVariable:路径变量
可以在后台直接拿到页面传过来的数据,通过得到的数据来进行相应操作。
@GetMapping("/question/{id}")
public String question(@PathVariable(name = "id") Integer id,
Model model) {
QuestionDTO questionDTO = questionService.getById(id); model.addAttribute("question", questionDTO);
return "question";
}
5.拦截器:Interceptor
在运行网页之前,先进行某些操作。
6.退出登录操作的实现
在html中将退出登录映射到 /logout
<li><a href="/logout">退出登录</a></li>
// 在相应的controller中实现退出登录操作
@GetMapping("/logout")
public String logout(HttpServletRequest request,
HttpServletResponse response) {
// 将session从页面中移除
request.getSession().removeAttribute("user");
// 将自定义的 token cookie从页面中移除
Cookie cookie = new Cookie("token", "null");
cookie.setMaxAge(0);
response.addCookie(cookie);
return "redirect:/";
}
7.在html中接受id属性
<!--用于接收 id属性-->
<input type="hidden" name="id" th:value="${id}">
8.集成Mybatis Generator:http://mybatis.org/generator/
(1)在pom文件中加入相关插件
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.4.0</version>
需要驱动
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.18</version>
</dependency>
</dependencies>
</plugin>
(2)在resources下建立generatorConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorCon