JSP中输出Enum
来源:互联网 发布:mac系统怎么关闭程序 编辑:程序博客网 时间:2024/05/17 08:02
Enum类
/** * */package com.example.enums;/** * @author Administrator * */public enum EnumType { BLOG("blog", "博客"), QUESTION("question", "提问"), ESSAY("essay", "随笔"); private String code; private String desc; private EnumType(String code, String desc) { this.code = code; this.desc = desc; } public static EnumType getCode(String code) { for (EnumType type : EnumType.values()) { if (type.getCode().equals(code)) { return type; } } return null; } /** * @return the code */ public String getCode() { return code; } /** * @param code the code to set */ public void setCode(String code) { this.code = code; } /** * @return the desc */ public String getDesc() { return desc; } /** * @param desc the desc to set */ public void setDesc(String desc) { this.desc = desc; }}
页面
<%@page import="com.example.enums.EnumType"%><%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><c:set var="types" value="<%= EnumType.values() %>"/><c:forEach var="type" items="${types}"> ${type.getCode() }, ${type.getDesc() }</c:forEach>
参考链接:http://blog.csdn.net/kinginblue/article/details/51458576
阅读全文
0 0
- JSP中输出Enum
- Enum.ToString不宜直接输出到界面或文件中
- c++11中输出enum class变量的数值
- JSP中输出CSV文件
- JSP中输出Excel表格
- 在jsp页面中输出
- tomcat7 jsp中enum关键字的忽略检查
- JSP,Enum,switch( XX )
- JSP中捕获 OUT 输出的例子
- 关于JSP中字符串输出问题
- jsp中输出一张表内容
- jsp中EL表达式原样输出问题
- 在jsp中输出异常信息
- JSP页面中禁止输出空行
- 在jsp页面中输出json格式
- enum 枚举类型 选择输出
- JSP输出
- ibatis中使用Enum
- echart3实用技巧整理
- 51nod1423 最大二“货”
- 解决firefox设置不自动更新后仍然自动更新问题
- Mongodb数据导出和导入
- 实战 | 这是一个转型AI的励志故事,从非科班到拿下阿里云栖一等奖,他经历的坑足够你学习100天
- JSP中输出Enum
- JAVA 正则表达式
- JS实现倒计时精确到天数,时,分,秒或者精确到时、分、秒(小时数累加)
- Hadoop/MapReduce购物篮分析:关联规则挖掘
- UVALive
- Ubuntu 16.04 静态IP地址的设置
- [状态压缩DP+三进制] HDU 3001
- 对象串行化
- eclipse打开文件所在位置