我有以下课程:
Types.java:
public class Types {
public static class PC {
public static enum Motherboard {
OPTION1("option 1"),
OPTION2("option 2"),
OPTION3("option 3");
private final String displayValue;
private Motherboard(String displayValue) { this.displayValue = displayValue; }
public String getDisplayValue() { return this.displayValue; }
}
};
};
在我的Thymeleaf模板中,我有:
<select name="select-motherboard">
<option th:each="size : ${T(jre.maintainme.utils.strings.Types.PC.Motherboard).values()}" th:value="${size}" th:text="${size.displayValue}"></option>
</select>
但是,这似乎不起作用。但是,如果我将主板枚举放入Types类中,它确实...是否有一种方法无法将枚举嵌套在类中并在Thymeleaf中使用它们?
解:
为了进入嵌套类,您需要在它们之间添加$。即:
${T(jre.maintainme.utils.strings.Types$PC$Motherboard)}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句