2012-03-01 118 views
0

我试图完成的JSP标签下面:春季选择标签

select.tag

<%@ attribute name="id" required="true" %> 
<%@ attribute name="path" required="true" %> 
<%@ attribute name="items" required="true" %> 
<%@ attribute name="itemLabel" required="false" %> 
<%@ attribute name="itemValue" required="false" %> 

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> 
<form:select path="${path}" id="${id}"> 
    <form:options items="${items}" itemLabel="${itemLabel}" itemValue="${itemValue}"/> 
</form:select> 

用法:(mycollectionattribute与@ModelAttribute( “mycollectionattribute” 定义))

<tags:select items="${mycollectionattribute}" id="id" path="mybean.selectvalue" itemLabel="label" itemValue="id"/> 

然而,我无法弄清楚如何正确地从调用页面映射项的集合来此标记。 EL似乎并没有进行评估,被作为一个字符串,引起以下错误:

javax.servlet.ServletException: Type [java.lang.String] is not valid for option items 

我用一个很老的版本JSTL,一个与JBoss 4.04GA捆绑在一起的,这可能是问题?我不确定EL表达式是否准确评估,直接在标记中的$ {x}不会评估,例如它只能用于特殊标记。升级可能解决这个问题?如果是这样,使用自己的JSTL库而不是JBoss捆绑的库有多难?

回答

0

已解决。

使用的是不匹配的servlet版本(2.5指定,但JBoss 4使用2.4),都作为依赖项,并在web.xml中。所以EL没有像应该那样工作。