/** * 下拉选项返回模型对象 created by tely on 2015/06/15. */ @Data public class SelectBean implements Serializable { private String key; private String value; private List<SelectBean> subObj; }package com.ig.sid.syssetting.util; /** * 国家枚举类 * Created by tely on 2015/8/13. */ public enum CountryEnum { COUNTRY_ENUM_CN("enum_country_cn","CN"),//中国 COUNTRY_ENUM_VN("enum_country_vn","VN"),//越南 COUNTRY_ENUM_TH("enum_country_th","TH"),//泰国 COUNTRY_ENUM_ID("enum_country_id","ID"),//印度尼西亚 COUNTRY_ENUM_JP("enum_country_jp","JP"),//日本 COUNTRY_ENUM_KH("enum_country_kh","KH"),//柬埔寨 COUNTRY_ENUM_KP("enum_country_kp","KP");//韩国 private String nameKey; private String code; public String getNameKey(){ return this.nameKey; } public String getCode(){ return this.code; } //构造函数必须为private的,防止意外调用 private CountryEnum(String nameKey, String code){ this.nameKey = nameKey; this.code = code; } }/** * 查找所有国家填充下拉框 * @return list */ @RequestMapping("findCountryFillSelect") @ResponseBody public List<SelectBean> findCountryFillSelect(HttpSession session) { List<SelectBean> list = new ArrayList<SelectBean>(); try{ SelectBean bean ; for(CountryEnum e: CountryEnum.values()){ bean = new SelectBean(); bean.setKey(e.getCode()); bean.setValue(e.getNameKey()); list.add(bean); } }catch (Exception e) { logger.error(e.getMessage()); } return list; }
jsp下拉框展示枚举定义的信息,java下拉框定义枚举赋值
最新推荐文章于 2021-02-16 11:25:29 发布