多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
![](https://box.kancloud.cn/5b5de11a654f17ea5d1d2a0d52307a12_778x431.png) 1. html ~~~ <div class="form-group col-md-6 col-sm-6 "> <label class="control-label col-md-4 col-sm-4 " for="authorId">作者</label> <div class="col-md-8 col-sm-8 "> <select id="authorId" name="authorId" class="form-control"> <option></option> <%for(moocUser in moocUsers){%> <option value="${moocUser.id}" >${moocUser.nickName}</option> <%}%> </select> </div> </div> ~~~ 2. controller ~~~ //打开添加专辑页面 @RequestMapping(value = "/viewadd", method = RequestMethod.GET) public String bookManageAdd(Model model) { List<MoocUser> moocUsers = moocUserMapper.selectByExample(new MoocUserExample()); model.addAttribute("moocUsers",moocUsers); return "busi/book/book_manage_add"; } ~~~ 3. js 设置回显 ~~~ var authorIdSelect = $("#authorId"); var authorId = authorIdSelect.attr("tag"); if (authorId) { authorIdSelect.select2().val(authorId).trigger("change"); //回显 } ~~~ ![](https://box.kancloud.cn/70741d3e4dae79c3aeadc369f7ba1184_786x392.png)