Comparing the enum constants in thymeleaf

前端 未结 10 2052
自闭症患者
自闭症患者 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:06

    Another option is using the method name() of the enum in a switch. An example would be:

      
         
         
      
    

    It is similar to a Java Switch swith ENUM instead of other answers like ${day == T(my.package.MyEnum).MONDAY} or ${#strings.toString(someObject.constantEnumString) == 'ONE'} which looks very strange.

提交回复
热议问题