企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
![](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)