Accessing enumerations in JSP

I’m posting this here just because it took me a little while to find. Let’s say you have an enumeration:
enum OperationType {REDIRECT, POST, NONE}

and you need to make some decision in your JSP page based on the chosen OperationType. How do you refer to the enumeration? Apparently you do this:

<c:if test="${myClass.myOperationType == 'REDIRECT'}">

You need to refer to the enumerations not by their fully qualified class name but by the String version of them. Note: I believe this might only work in Unified EL.

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment

Spam protection by WP Captcha-Free