如何在 thymeleaf 中迭代 Guava multimap

How to iterate Guava multimap in thymleaf

我有以下地图集。我想在 thymeleaf 中重复这个但是低于错误。

Multimap<String,String> map = ArrayListMultimap.create();

<div th:each="m : ${menu.entries}">

EL1008E: 在类型 'com.google.common.collect.ArrayListMultimap' 的对象上找不到 属性 或字段 'entries' - 可能不是 public 或无效?

这是在 Thymeleaf 中迭代番石榴多图的一种方法。

部分测试数据:

Multimap<String, String> map = ArrayListMultimap.create();
map.put("key one", "value one");
map.put("key two", "value two a");
map.put("key two", "value two b");
map.put("key three", "value three");

百里香叶:

<div th:each="k : ${menu.keySet()}">
    <div th:text="'key is: ' + ${k}">
    </div>
    <div th:each="v : ${menu.get(k)}">
        <div th:text="'val is: ' + ${v}">
        </div>
    </div>
</div>

这会在网页中产生以下输出(不保证顺序):

key is: key two
val is: value two a
val is: value two b
key is: key one
val is: value one
key is: key three
val is: value three