枚举类
package com.demonstration.entity;
import java.util.List;
import java.util.Map;
public enum ReviewStatus {
//以下是枚举类的对象
FINISH("复审通过",0),
REVIEW_NOT("复审未通过",1),
TRIAL("待初审",2),
REVIEW("待复审",3),
MODII("退回修改",4);
public static void resetKey(List<Map<String, Object>> maps) {
//此方法中无需写内容
}
public static ReviewStatus getByName(String name) {
for (ReviewStatus reviewStatus : ReviewStatus.values()) {
if (reviewStatus.name().equals(name)) {
return reviewStatus;
}
}
return null;
}
public static ReviewStatus getByNum(Integer num) {
for (ReviewStatus reviewStatus : ReviewStatus.values()) {
if (reviewStatus.getNum()==num) {
return reviewStatus;
}
}
return null;
}
public String firstBigLetter() {
return this.name().substring(0, 1);
}
private String desc;
private int num;
private ReviewStatus(String desc,int num) {
this.desc = desc;
this.num = num;
}
private ReviewStatus(String desc) {
this.desc = desc;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}
将其内容放到页面上
modelMap.put("reviewStatus",ReviewStatus .values());
//values()方法获得所有的枚举对象,返回的是一个数组
//valueOf(String name)方法传入的name要是枚举类对象的名字,获得是一个相应的枚举对象
页面显示
<select>
<#list reviewStatus as data>
<option value="${(data.getNum())!}">${(data.getDesc())!}</option>
</#list>
</select>