I have an Enum called Status defined as such:
public enum Status { 
    VALID("valid"), OLD("old");
    private final String val;
    Status(String val) {
        this.val = val;
    }
    public String getStatus() {
        return val;
    }
}
I would like to access the value of VALID from a JSTL tag. Specifically the test attribute of the <c:when> tag. E.g.
<c:when test="${dp.status eq Status.VALID">
I'm not sure if this is possible.
A simple comparison against string works:
<c:when test="${someModel.status == 'OLD'}">
                        If using Spring MVC, the Spring Expression Language (SpEL) can be helpful:
<spring:eval expression="dp.status == T(com.example.Status).VALID" var="isValid" />
<c:if test="${isValid}">
   isValid
</c:if>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With