Вопрос

I have an enum:

enum DestinationTab{
        Overview,
        ThingsTodo
    };

I set an enumSet in my action class based on certain conditions. On my jsp, I'd like to render only those sections which are present in this enumSet.

This construct doesn't work:

   <s:if test="eSet.contains('ThingsTodo')">
    print something
   </s:if>

How can I use enumSet.contains(..) in jsp ?

Это было полезно?

Решение

An EnumSet contains Enumeration members, not strings.

To get an enumeration member, you can use valueOf :

<s:if test="eSet.contains(DestinationTab.valueOf('ThingsTodo'))">
 print something
</s:if>

Or, when the specific member to use is hardcoded :

<s:if test="eSet.contains(DestinationTab.ThingsTodo)">
 print something
</s:if>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top