jsp自定义标记中的Spring select标记

时间:2012-03-01 10:54:41

标签: jsp spring-mvc el jsp-tags jboss-4.0.x

我正在尝试在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捆绑的库有多难?

1 个答案:

答案 0 :(得分:0)

解决。

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

相关问题