Comparing the enum constants in thymeleaf

前端 未结 10 2083
自闭症患者
自闭症患者 2021-02-02 06:25

I have an enum, Constants:

enum Constants {
    ONE,TWO,THREE;
}

How can I compare the enum Constants in Thymeleaf.

Thank

10条回答
  •  广开言路
    2021-02-02 07:02

    If you don't want to convert your Enum into a string in your object you can do it like this:

    th:if="${#strings.defaultString(someObject.myConstant, 'DEFAULT_VALUE') == 'ONE'}"
    

提交回复
热议问题