문제

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