Comparing the enum constants in thymeleaf

user3128455 picture user3128455 · Jul 24, 2014 · Viewed 35.2k times · Source

I have an enum, Constants:

enum Constants {
    ONE,TWO,THREE;
}

How can I compare the enum Constants in Thymeleaf.

Thanks.

Answer

Nick picture Nick · Feb 17, 2015

To compare with an enum constant, use the following code:

th:if="${day == T(my.package.MyEnum).MONDAY}"