سؤال

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