删除员工实现
1、list页面,编写提交地址
<a class="btn btn-sm btn-danger" th:href="@{'/delEmp/'+${emp.getId()}}">删除</a>
2、编写对应的Controller
//删除员工
@GetMapping("/delEmp/{id}")
public String deleteEmp(@PathVariable("id") Integer id){
employeeDao.delete(id);
return "redirect:/emps";
}
404及注销功能实现
404
我们只需要在模板目录下添加一个error文件夹,文件夹中存放我们相应的错误页面;
比如404.html 或者 4xx.html 等等,SpringBoot就会自动识别并使用了!
注销
1、注销请求
<a class="nav-link" th:href="@{/user/logout}">注销</a>
2、编写对应的controller
@RequestMapping("/user/logout")
public String logout(HttpSession session){
session.invalidate();
return "redirect:/index.html";
}