通用的枚举类型
写一个接口
[java]
public inte易做图ce DisplayEnum {
public String getDisplay();
}
接着写枚举
[java]
/**
* 性别
*/
public enum SexType implements DisplayEnum {
MEN("M"),
FELMEN("F");
private String value;
private SexType(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
private static Map<String, String> labelMap = new LinkedHashMap<String, String>();
static {
SexType.labelMap.put(SexType.MEN.getValue(), "男");
SexType.labelMap.put(SexType.FELMEN.getValue(), "女");
}
public static Map<String, String> getLabelMap() {
return SexType.labelMap;
}
@Override
public String getDisplay() {
return SexType.labelMap.get(this.getValue());
}
}
jsp中用spring标签来引入枚举类型
[java]
<spring:eval
expression="T(com.overallsituation.SexType).getLabelMap()"
var="易做图Type"></spring:eval>
<select name="易做图Type" class="select" reg="\S">
<c:forEach var="map" items="${易做图Type}">
<option value="${map.key }" ${command.易做图Type==map.key?'selected':''}>
${map.value }
</option>
</c:forEach>
</select>
补充:软件开发 , Java ,