Thymeleaf select 反显 默认选中

2019-12-16  本文已影响0人  Morgan7

后台代码

List<ExamTestPaperDO> list = examTestPaperService.list(map);
model.addAttribute("testPaper",list);
model.addAttribute("testPaperId",request.getParameter("testPaperId"));

页面代码

<select  id = "testPaperId" name="testPaperId" class="form-control">
    <option value="">所有</option>
    <option th:each="test : ${testPaper}" th:value="${test.id}" th:text="${test.name}" th:selected="${test.id eq testPaperId}"></option>
</select>
上一篇下一篇

猜你喜欢

热点阅读