Spring Boot, Thymeleaf. Вывод записей из БД - Аккаунт, пароль и роль

HTML

<section class="addNewStaff">
    <h1 >Список аккаунтов</h1>

    <div class="allDivName">
        <div class="staffsName1">Логин</div>
        <div class="staffsName1">Пароль</div>
        <div class="staffsName1">Роль</div>
    </div>

    <div th:each="el : ${accounts}" th:object="${userForm}"  >
<!--        <input type="text" th:field="*{id}" th:value="${userForm.id}">-->
        <div class="allDivName" >
            <div th:text="${el.username}"></div>
            <div th:text="${el.password}"></div>
        </div>

        <form  th:action="'/admin-account/' + ${el.id} +'/remove'" method="post">
            <button class="btnDelete" type="submit">Удалить</button>
        </form>

    </div>
<!--        <input type="text" th:field="*{roles}" >-->
            <div th:each="role : ${listRoles}"  class="allDivName">
                <div th:text="${role.name}"></div>
            </div>

</section>

Controller

@GetMapping("/admin-account")
    public String adminAccount( Model model) {
        Iterable<Role> roles = roleRepository.findAll();
        Iterable<Account> accounts = accountRepository.findAll();
        model.addAttribute("listRoles", roleRepository.findAll());
        model.addAttribute("userForm", new Account());
        model.addAttribute("roles", roles);
        model.addAttribute("accounts", accounts);
        model.addAttribute("title", "Аккаунты");
        return "adminHTML/account";
    }

введите сюда описание изображения

Доброго времени суток! Подскажите пожалуйста, как я могу выводить роль у конкретного аккаунта?


Ответы (0 шт):