首页 > 解决方案 > Thymeleaf 下拉列表 + 引导程序

问题描述

在我的应用程序中,我有一个使用枚举值的 thymeleaf 下拉列表。

我想将它与引导程序连接以使其具有更好的方面,我试图自己做,并试图在互联网上找到一些帮助,但仍然没有。

我的下拉列表:

<div class="dropdown">
<form th:object="${money}" th:action="@{saveOperation}" action="#" method="post">

    <select th:field="*{name}">

        <option th:each=" value : ${T(com.bartosz.kolej.whereismymoney.operations.model.MoneyOperations.OperationsNames).value()}"
                th:value="${value}"
                th:text="${value.getDisplayName()}">
        </option>

    </select>
    <input type="number" required th:field="*{value}" class="form-controll" placeholder="value" step="0.01  "/>
    <input type="submit" class="btn btn-warning" th:value="Save"/>

</form>

我想将它插入这样的代码中:

<div class="dropdown show">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown"
   aria-haspopup="true" aria-expanded="false">
    Dropdown link
</a>

<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <a class="dropdown-item" href="#">Something else here</a>
</div>

标签: javabootstrap-4thymeleaf

解决方案


像这样的东西:

<div class="dropdown show">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown"
    aria-haspopup="true" aria-expanded="false">
    Category
</a>

<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
    <div th:each="c:${categories}">
        <a class="dropdown-item" href="#" th:text="${c.getCategoryName()}">Action</a>
    </div>
</div>


推荐阅读