質問

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