Thymeleaf

Thymeleaf枚举

enum

public enum JkCashBackEnumMode {

    SINGLE(2, "一次性给到到期日"),
    YEAR(4, "根据投资日按年"),
    CUSTOM(6, "自定义返现");

    private int code;
    private String text;

    JkCashBackEnumMode(int code, String text) {
        this.code = code;
        this.text = text;
    }

    public static JkCashBackEnumMode getModeByCode(int code) {
        for (JkCashBackEnumMode e : values()) {
            if (e.code == code)
                return e;
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
}

html

            模式:
            <span class="select-box inline">
                <select th:name="mode" class="select" style="width: 150px;">
                    <option value="">全部</option>
                    <option th:each="enum:${T(com.jkinvest.constant.JkCashBackEnumMode).values()}" th:value="${enum.code}" th:text="${enum.text}"></option>
                </select>
            </span>
        <tbody>
            <tr class="text-c" th:each="model:${pageInfo?.list}">
                <td>
                    <span th:each="enum:${T(com.jkinvest.constant.JkCashBackEnumMode).values()}" th:if="${model.mode eq enum.code}" th:text="${enum.text}"></span>
                </td>
            </tr>
        </tbody>
            
下拉选择
       <span class="select-box inline"> <select th:name="status" class="select" style="width: 150px;"> <option value="">全部</option> <option th:each="enum:${T(com.jkinvest.constant.ProjectStatus).values()}" th:selected="${status eq enum.code}" th:value="${enum.code}" th:text="${enum.text}"></option> </select> </span>

 

posted on 2019-09-16 17:33  1zfang1  阅读(179)  评论(0编辑  收藏  举报

导航