枚举的声明:
public class Test {
public static enum ExceptionType {
NORMAL("正常"), FREEZE("冻结");
ExceptionType(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public setName(String name){
this.name = name;
}
public static ExceptionType getExceptionType(String name) {
for(ExceptionType type: ExceptionType.values()) {
if(type.name.equals(name)) {
return type;
}
}
return null;
}
private String name;
}
}
struts2引用枚举:
<s:select list="com.test.xiaotian.Test$ExceptionType@values()"
listKey="name()" listValue="name" headerKey="" headerValue=""/>