![](/img/trans.png)
[英]How to display all enum values in Spring using Thymeleaf and Bootstrap
[英]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.