Search code examples
javaenumsthymeleaf

How to display one value of enum with Thymeleaf


My enum:

public enum USER_TYPE { administrator, manager, worker };

        private GENDER gender;

My html :

<div class="form-group">
            <label class="col-sm-2 control-label"> User type:</label>
             <div class="col-xs-5 selectContainer">
             <select class="form-control" name="size" th:field="*{userType}">
                <option  th:each="userType : ${T(com.people.User.USER_TYPE).values()}" th:value="${userType}" th:text="${userType}"></option>


            </select>

I managed to display all values of enum, but how to display as example just manager value ?


Solution

  • <option th:value="${T(com.people.User.USER_TYPE).manager}" 
            th:text="${T(com.people.User.USER_TYPE).manager}"></option>