Thymeleaf select 反显 默认选中


后台代码

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

页面代码

关键代码th:selected="${test.id eq 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>
 
  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。