Liver Liver - 1 year ago 67
Java Question

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>


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

Answer Source
<option th:value="${T(com.people.User.USER_TYPE).manager}" 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download