11

I have the following class

package com.test;

public class SomeClass {
   public enum COLOR {RED,BLUE}
}

I want to access values of COLOR enum in my JSP. I've tried the following code but it doesn't work.

<s:property value="@com.test.SomeClass.COLOR@RED"/>
<s:property value="@com.test.SomeClass@COLOR.RED"/>

Any body came across this issue before? [I've already enabled static method access in struts.xml]

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
Dev Blanked
  • 8,555
  • 3
  • 26
  • 32

1 Answers1

16

For enum-s there is not need to enable static method access.

Enum-s can be accessed using @ sign like that:

<s:property value="@package.ENUM@enumvalue"/>

In your case since you are declaring enum inside class use $ sign to refer to your enum.

<s:property value="@com.test.SomeClass$COLOR@RED"/>
Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
  • 2
    I wish I'd have come across this answer weeks ago. The `$` is what I was missing since my `enum`s are declared inside other classes. – Matt Sep 29 '16 at 12:58