给定一个包含枚举的类:
public class MyClass {
public enum NestedEnum {
value1(1),
value2(2);
private int code;
private NestedEnum(int code) {
this.code = code;
}
public int getCode() {
return code;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我如何引用NestedEnum?这个:
#{T(MyClass.NestedEnum).value1.getCode()}
Run Code Online (Sandbox Code Playgroud)
结果例外:
org.springframework.expression.spel.SpelEvaluationException: EL1005E:(pos 0): Type cannot be found 'namespace.MyClass.NestedEnum'
Run Code Online (Sandbox Code Playgroud)
这个:
#{T(T(MyClass).NestedEnum).value1.getCode()}
Run Code Online (Sandbox Code Playgroud)
结果例外:
org.springframework.expression.spel.SpelParseException: EL1043E:(pos 3): Unexpected token. Expected 'rparen())' but was 'lparen(()'
Run Code Online (Sandbox Code Playgroud)
我想不出任何其他好的选择.
mic*_*fra 21
您必须使用$符号分隔枚举:
#{T(MyClass$NestedEnum).value1.getCode()}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6668 次 |
| 最近记录: |