4

I've been looking for documentation on Thymeleaf's 'new' switch case but either I'm looking in the wrong places, or there isn't too much of it. Anyhow, here's my issue:

<div th:switch="${profileModel.goal}">
    <p th:case="*">No goal specified</p>
    <p th:case="1">Lose weight</p>
    <p th:case="2">Gain muscle</p>
    <p th:case="3">Overall fit</p>
</div>

Now I know for a fact that ${profileModel.goal} is either 1, 2 or 3. I checked by simply printing the value in a paragraph above it, but the printed message is always 'No goal specified'.

Is it not possible to switch over integers or am I going to have a facepalm moment soon?

Roel Strolenberg
  • 2,922
  • 1
  • 15
  • 29

1 Answers1

5

Your default case should be at the end, not the beginning.