1.Controller逻辑
@GetMapping("/user/delete/{id}")
public String deleteUser(@PathVariable("id") Long id,
@RequestParam(value = "pn",defaultValue = "1") Integer pn,
RedirectAttributes ra){
userService.removeById(id);
// 重定向添加参数
ra.addAttribute("pn",pn);
return "redirect:/dynamic_table";
}
2.删除按钮
<td><a th:href="@{/user/delete/{id}(id = ${user.id},pn=${page.current})}" class="btn btn-danger" type="button">Delete</a></td>
重定向添加参数
ra.addAttribute("pn",pn);
return "redirect:/dynamic_table";
相当于: