Reputation: 2524
I have an enum
public enum Number
{
ONE("one"), TWO("two"), THREE("three"), FOUR("four");
}
i put this enum into model
model.addAttribute("myEnum", Number.values());
Now, in jsp page I want to show a value of one of these enums.
<c:out value="${myEnum.ONE}"/>
but it doesnt seem to work. What am I doindg wrong?
Upvotes: 3
Views: 5642
Reputation: 47280
myEnum is a list of values returned, you could either create one attribute equal to the value of one enum instance :
model.addAttribute("one", Number.ONE);
<c:out value="${one}"/>
or loop through myEnum :
<c:forEach items="${myEnum}" var="value">
${value}
</c:forEach>
Upvotes: 4