<mytaglib:mytag enumParam="${now what do I type here?}" />
到目前为止我发现的唯一的解决方法是使枚举是一个整数,并将其转换为所需的值:
<mytaglib:mytag enumParam="3" />
我相信一定要有更好的办法.请帮忙.
EL允许使用枚举!There are three ways to set a tag attribute value using either an rvalue or lvalue expression:
[..]With text only:
<some:tag value=”sometext”/>
This expression is called a literal expression. In this case, the attribute’s String value is coerced to the attribute’s expected type. Literal value expressions have special syntax rules. See Literal Expressions for more information. When a tag attribute has an enum type, the expression that the attribute uses must be a literal expression. For example, the tag attribute can use the expression “hearts” to mean Suit.hearts. The literal is coerced to Suit and the attribute gets the value Suit.hearts.
http://download.oracle.com/javaee/5/tutorial/doc/bnahq.html
枚举:
public Enum Color{ RED, BLUE, GREEN }
JSP / Tag文件
<mytaglib:mytag enumParam="${'RED'}" />
测试与Tomcat 7.0.22以及Jetty 6.1.26.