1.实体类
dao下的entity实体类
添加一个Department 属性
注意:
1.员工的添加 编辑需要用到,所在部门和职务
在list界面点击添加时
<button type="button" class="btn btn-default light">
<i class="fa fa-plus" onclick="javascript:window.location.href='/employee/to_add';"></i>
</button>
跳转到跳到to_add 控制器
@RequestMapping("/to_add")
public String toAdd(Map<String,Object> map){
map.put("employee",new Employee());
map.put("dlist",departmentBiz.getAll());
map.put("plist", Contant.getPosts());
return "employee_add";
}
携带员工的部门,职务选项 通过${dlist} ${plsit} 在employee_add.jsp 显示
<form:input path="sn" cssClass="gui-input" placeholder="工号..." />
<form:input path="name" class="gui-input" placeholder="姓名..."/>
<form:select path="departmentSn" items="${dlist}" itemLabel="name" itemValue="sn" cssClass="gui-input" placeholder="所属部门..."/>
<i class="arrow double"></i>
<form:select path="post" items="${plist}" cssClass="gui-input" placeholder="职务..."/>
<i class="arrow double"></i>
通过 <button type="submit" class="button"> 保存 </button>
提交到了
<form:form action="/employee/add"
add Controller
@RequestMapping("/add")
public String add(Employee employee){
employeeBiz.add(employee);
return "redirect:list";
}