thymeleaf-spring icon indicating copy to clipboard operation
thymeleaf-spring copied to clipboard

Thymeleaf throwing error Exception evaluating SpringEL expression, for lists in HashMap

Open sathishvenkataraman opened this issue 3 years ago • 0 comments

I have this code

HashMap<String, List<String>> shopCat; data goes like this: shopCat => {"Vegetables":["Carrot",...], "Fruits":["Apple",....]}

model.addAttribute("shopCat", shopCat); View code:

    <tr th:each="sCat : ${shopCat}">
            <tr th:each="sList: ${sCat.value}">
                <tr th:each="item: ${sList}">
                    <td th:text="${item}"></td>
             ...

I get this error: Exception evaluating SpringEL expression: "sCat.value"

interestingly if I try to print key and value of sCat, it prints, but cannot iterate..

    <tr th:each="sCat : ${shopCat}">
            <td th:text="${sCat.key}"></td>
            <td th:text="${sCat.value}"></td>
             ...

output: Veg=[Carrot, Potato] Fruits=[Apple, Melon]

sathishvenkataraman avatar Mar 13 '22 07:03 sathishvenkataraman