是否可以檢查二維數(shù)組中是否存在特定元素?<div th:each="employee, i : ${company.employees}"><div th:each="duty, j : ${employee.duties}"> <div class="custom-control custom-checkbox my-1 mr-sm-2"> <input type="checkbox" name="duties" th:id="${j.index}" th:value="${j.index}" th:checked="${#arrays.contains(${company.tasks[i.index][]}, ${duty.id})}" /> <label th:for="${j.index}" th:text="${j.index}"></label> </div></div></div>Java 等效項應(yīng)該是:for (int i=0; i<company.getEmployees().length; i++) for (Duty duty : company.getEmployees().[i].getDuties()) boolean checked = company.getTasks()[i].contains(duty.id); // Contains, method that checks whether element exists on array
Thymeleaf 中的多維數(shù)組搜索?
慕桂英3389331
2021-07-08 14:08:22