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刪除。