java枚举类型 jsp select_java枚举类型转换为Struts2的select的数据

枚举类:AppSortEnum.java

public enum AppSortEnum {

CORE(0, "核心应用"),

ENJOYMENT(1, "娱乐应用"),

MESSAGE(2, "消息提醒");

private int index;

private String name;

public int getIndex() {

return index;

}

public void setIndex(int index) {

this.index = index;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

private AppSortEnum(int index, String name) {

this.index = index;

this.name = name;

}

}

在Action中使用:

public String presentUI(){

ActionContext.getContext().put("appSort", AppSortEnum.values());

ActionContext.getContext().put("appType", AppTypeEnum.values());

ActionContext.getContext().put("range", areaService.queryAll());

return "presentUI";

}

在jsp中使用appSort和appType:

类型:分类:

*

效果:

e546cfe6f599b3c5eed980f399af6a1a.png

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页