繁体   English   中英

如何在百里香叶中显示枚举值?

[英]How to display enum getter value on view in thymeleaf?

我有一个这样的枚举:

public enum UnitTypes {

LITER("l"), KILO("kg"), PIECE("pc");

private String unitType;

UnitTypes(String type) {
    this.unitType = unitType;
}

String getType() {
    return unitType;
}

}

如何在视图上显示getType方法中的单个值?

我尝试了这个,但是不起作用:

<td th:text="${stock.unit.getType()}"></td>

在“股票”中,我有一个字段,这是此枚举类型(“单位”)

UnitTypes(String type) {
    this.unitType = unitType;
}

该代码应为

UnitTypes(String type) {
    this.unitType = type;
}

您在原始代码中为其分配unitType。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM