jsp下拉框展示枚举定义的信息,java下拉框定义枚举赋值
2016-12-14 15:59
323 查看
/** * 下拉选项返回模型对象 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; }
相关文章推荐
- 【javaweb:jsp】从服务器获取动态商品信息并展示在jsp中
- Java语言基础07-变量定义与赋值
- 错误信息:java.lang.NoSuchMethodError: javax.servlet.JSP.PageContext.getELContext()LJAVAx/el/ELContext
- 关于在jsp页面写java代码的分析(限定用户查看相关的信息)
- 开源jxls - java导Excel(多sheet) - 模板文件定义类似jsp的el表达式
- JavaBean定义、JSP中使用以及内省操作
- servlet规范定义的Servlet生命周期 - Java - J2EE - Servlet/JSP - linux宝库
- java 定义枚举+枚举使用
- java中数组的定义和赋值
- 提高你的Java代码质量吧:推荐使用枚举定义常量
- Java EE WEB工程师培训-JDBC+Servlet+JSP整合开发之14.Servlet请求头信息
- MyEclipse设置JSP页面编码方式以及Java中作者、日期、版本信息
- MyEclipse设置JSP页面编码方式以及Java中作者、日期、版本信息
- java 定义枚举+枚举使用
- 定义java的枚举变量
- MyEclipse .java .jsp .js页面 自动弹出信息提示框
- 【java】JCombox事件消息,下拉框每一项增加提示信息,也适用于模糊查询
- Java枚举赋值字符类型
- java 枚举(括号赋值)