0

Here is the enum I have

    public enum CategoryDto {
    DRINKS,
    BURGERS,
    SNACKS
}

Here is how I print them out using Thymeleaf in my Spring Boot project

 <select class="form-select" aria-label="Choose category">
 <option th:each="category : ${T(com.exampleepam.restaurant.dto.CategoryDto).values()}"
 th:value="${category}" th:text="${category}"></option>
 </select>

Pretty easy, now I have select filled with my enums. enter image description here

But how can I do the same in JSP without thymeleaf in Servlet project?

  • 1
    You could look at https://stackoverflow.com/questions/29465943/get-enum-values-as-list-of-string-in-java-8 Once you have a list, you can do what you want to do. – rickz Feb 20 '22 at 19:02

0 Answers0