您的位置:首页 > 编程语言 > Java开发

java枚举和Struts2的使用

2013-10-14 16:46 295 查看
枚举的声明:

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=""/>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: