编辑页面
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/c022034e9f96094df02320f3f6d063b0.png)
controller中的方法
@RequestMapping(path="/toUpdate",method ={ RequestMethod.GET, RequestMethod.POST})
public String toUpdate(Model model, String deptId){
String companyId = "1";
l.info("toUpdate deptId="+deptId);
Dept dept = iDeptService.findById(deptId);
l.info("toUpdate dept="+dept);
List<Dept> list = iDeptService.findAll(companyId);
model.addAttribute("dept",dept);
model.addAttribute("list",list);
return "system/dept/dept-update";
}
下拉菜单回显
<select class="form-control" name="parent.deptId">
<option value="">成为顶级部门</option>
<c:forEach items="${list}" var="item">
<option ${dept.parent.deptId == item.deptId ?'selected':''} value="${item.deptId}">${item.deptName}</option>
</c:forEach>
</select>
select标签的回显
<select name="parentId">
<option value="1">部门1</option>
<option value="2">部门2</option>
<option selected value="3">部门3</option>
<option value="4">部门4</option>
</select>
单选的回显
<div class="form-group form-inline">
<div class="radio"><label><input type="radio" ${dept.state==0?'checked':''} name="state" value="0">停用</label></div>
<div class="radio"><label><input type="radio" ${dept.state==1?'checked':''} name="state" value="1">启用</label></div>
</div>
单选框的回显
<input type="radio" name="sex" value="1" >男
<input type="radio" name="sex" value="0" checked >女