实现员工添加页面
添加员工数据信息页面
步骤
- 我们需要点击按钮跳转到添加页面,这里我们使用了
a标签
进行跳转
<h2><a class="btn btn-sm btn-success" th:href="@{/emp}">添加员工</a></h2>
- Controller层处理逻辑,实现跳转,众所周知我们的
a标签
默认是get方法请求
@GetMapping("/emp")
public String toAddpage(Model model){
//查出所有部门的信息
Collection<Department> departments = departmentDao.getDepartments();
model.addAttribute("departments",departments);
return "emp/add";
}
- 添加对应的add页面
这里我们可以做到代码的复用,把list.html
简单修改一下
<form>
<div class="form-group">
<label>LastName</label>
<input type="text" class="form-control" placeholder="xiaozhoubg">
</div>
<div class="f