跟着做的一个小demo,但是我的添加按钮始终无法跳转
controller层:
//来到员工添加页面
@GetMapping("/emp")
public String toAddPage(){
return "emp/add";
}
前端按钮:
<h2><button class="btn btn-sm btn-success"href="emp"th:href="@{/emp}">员工添加</button></h2>
后来才发现,这应该是一个a标签而不是button,button不能直接加href属性,里面用了boostrap的样式和访问路径th:href="@{/emp}"
所以应该是
<h2><a class="btn btn-sm btn-success" href="emp" th:href="@{/emp}">员工添加</a></h2>