修改页面动态下拉框

14:32:05
<<< Controller层 >>>
1.首先根据参数id查询出当前列所对应的的医生信息
2.根据医生信息中的doctorCategoryid查询出当前分类信息,用于页面判断。
3.查询含有所有分类信息的List集合
4.通过Model向前台传递数据
 1 @RequestMapping("/doctorManager_update/{id}")
 2     public String doctorManagerUpdate(@PathVariable Integer id, Model model) {
 3         //查询医生,医生分类,分类列表
 4         Doctor doctor = doctorMapper.selectById(id);
 5         DoctorCategory doctorCategoryInfo = doctorCategoryDao.selectById(doctor.getDoctorCategoryid());
 6         List<DoctorCategory> list = doctorCategoryDao.selectList(null);
 7 
 8         model.addAttribute("list",list);
 9         model.addAttribute(doctor);
10         model.addAttribute("doctorCategoryInfo",doctorCategoryInfo);
11 
12         return PREFIX + "doctorManager_edit.html";
13     }

<<< 页面下拉框区域 >>>
1.通过for循环遍历分类集合数据。
2.通过if判断过滤重复选项
1 <#select id="doctorCategoryid" name="医生职务">
2   <option value="${doctorCategoryInfo.id}" hidden="${doctorCategoryInfo.id}">${doctorCategoryInfo.type}</option>
3   @for(doctorCategory in list){
4      @if(doctorCategory.id != doctorCategoryInfo.id){
5          <option value="${doctorCategory.id}">${doctorCategory.type}</option>
6        @}
7     @}
8 </#select>

<<< 效果图 >>>

1.下拉框中不显示已默认选中选项

猜你喜欢

转载自www.cnblogs.com/XieXiyu/p/11201021.html