我've created a custom JSP tag that is supposed to accept a list of products to render, but I'我无法弄清楚如何将列表传递给标签 . 产品列表作为页面范围的bean存在 . Web应用程序使用Struts taglib在Struts 1.2.x中编写 .
这是我的代码的简化版本:
renderProducts.tag
<%@ tag language="java" pageEncoding="ISO-8859-1" body-content="empty" %>
<%@ attribute name="products" required="false" type="ProductIf[]" %>
<logic:iterate id="product" name="${products}" type="ProductIf">
<!-- Render the product -->
</logic:iterate>
ProductDetail.jsp
<bean:define id="relatedProducts" name="productMgr" property="relatedProducts />
<my:renderProducts products="${relatedProducts}" />
但是,当我查看页面时,我得到一个例外:
无法将字符串“$ ”转换为类“[Lcom.foo.ProductIf;”属性“products”:Property Editor未向PropertyEditorManager注册
所以似乎 ${}
语法不是我需要做的,因为无论如何它被解释为文字字符串 . 我也试过传递没有 ${}
的bean的名称,结果相同 . 什么是正确的语法?
(注意:请原谅我,如果这个问题 Build 在糟糕假设的基础之上,但我是Java EE开发的新手,而且还有相当多的笨拙的蠢货 . )
1 回答
阅读http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html:
(强调我的)
因此,要么切换到servlet 2.4或更高的描述符,如果容器支持它,要么使用
<%@ page isELIgnored = "false" %>
激活EL .