码匠社区(实战笔记二)

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 generatorConfiguration
        PU
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值