我有一个带有键和描述的枚举,如下所示。在 JSP 中,我将获得值并且我想显示描述。
public enum STATUS {
ACTIVE("A", "Active"),
INACTIVE("I","Inactive"),
PENDING("PND","Pending");
private final String value;
private final String description;
public String getValue() {
return value;
}
public String getDescription() {
return description;
}
STATUS(String value, String description) {
this.value=value;
this.description = description;
}
public static STATUS fromValue(String value) {
if (value != null) {
for (STATUS status : values()) {
if (status.value.equals(value)) {
return status;
}
}
}
return getDefault();
}
}