通用的枚举类型
2013-10-09 16:16
369 查看
写一个接口
接着写枚举
jsp中用spring标签来引入枚举类型
public interface DisplayEnum { public String getDisplay(); }
接着写枚举
/** * 性别 */ 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标签来引入枚举类型
<spring:eval expression="T(com.overallsituation.SexType).getLabelMap()" var="sexType"></spring:eval> <select name="sexType" class="select" reg="\S"> <c:forEach var="map" items="${sexType}"> <option value="${map.key }" ${command.sexType==map.key?'selected':''}> ${map.value } </option> </c:forEach> </select>
相关文章推荐
- TypeScript基础入门 - 类型兼容性 - 枚举和类
- 黑马程序员——C语言热身——预处理指令、变量类型、static和extern、结构体、枚举
- 枚举类型
- 利用泛型和反射编写通用基础类型转换方法
- c++ 通用类型
- 学习枚举类型
- 浅谈asp.net中的枚举类型
- 遍历枚举类型
- 已知有枚举类型定义:enum MyEn{a=101,b,c=207,d,e,f,g},编程输出第5个枚举元素的序号值
- Swift 通用类型和通用函数 | Generic type and function
- WPF值通用的类型转换器详解(转)
- java 枚举类型
- 深度分析 Java 的枚举类型:枚举的线程安全性及序列化问题
- C++中enum枚举类型成员重名问题的解决方法
- 简单枚举类型——植物与颜色
- Java编程思想之枚举类型
- *Delphi的枚举类型
- Android For JNI(五)——C语言多级指针,结构体,联合体,枚举,自定义类型
- 枚举类型 enum,NS_ENUM,NS_OPTIONS
- JAVA中的枚举类型