【问题标题】:nested loop in select option in thymeleaf over map?在地图上百里香的选择选项中嵌套循环?
【发布时间】:2019-10-19 22:01:49
【问题描述】:

我将 包含整数和列表的地图从我的控制器类传递给查看。在视图内部,我有选择选项,我只想在选项中显示列表值,但我不知道如何实现。请帮我这样做。

控制器

Map<Integer, List<String>> deviceidsAndwhatToUpdateText = new HashedMap<Integer, List<String>>();

查看

<select class="form-control select-checkbox"
                id="WhatToUpdate" multiple="multiple">
                    <option th:each="idsAndText : ${deviceidsAndwhatToUpdateText}"

                         th:value="${idsAndText.value}"
                        th:utext="${idsAndText.value}">Wireframe</option>

            </select>

【问题讨论】:

    标签: spring-boot spring-mvc thymeleaf


    【解决方案1】:

    这将列出你地图中的所有字符串,这是你想要的吗?

    <select class="form-control select-checkbox" id="WhatToUpdate" multiple="multiple">
      <th:block th:each="idsAndText : ${deviceidsAndwhatToUpdateText}">
        <option th:each="text : ${idsAndText.value}" th:value="${text}" th:text="${text}" />
      </th:block>
    </select>
    

    【讨论】:

      猜你喜欢
      • 2019-10-14
      • 2013-11-26
      • 2018-03-19
      • 2020-10-31
      • 2014-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多