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]

4

1 回答 1

16

对于enum-s 不需要启用static method access

可以使用@如下符号访问 Enum-s:

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

在您的情况下,因为您enum在类内部声明使用$符号来引用您的enum.

<s:property value="@com.test.SomeClass$COLOR@RED"/>
于 2013-04-17T22:01:55.797 回答