1.Enum 代码
package com.java.enums;
public enum SerialEnum {
A(1, "A"),
B(2, "B"),
C(3, "C");
public String key;
public String value;
public String getKey() {
return key;
}
public String getValue() {
return value;
}
AreaSerialEnum(String key, String value) {
this.key = key;
this.value = value;
}
}
2.Thymeleaf模板遍历枚举键值
<select>
<option th:each="enmu : ${T(com.java.enums.SerialEnum).values()}"
th:value="${enmu.key}"
th:text="${enmu.value}">
</option>
</select>