【问题标题】:javax.el.PropertyNotFoundException: The class 'java.lang.Integer' does not have the property '0'javax.el.PropertyNotFoundException:类“java.lang.Integer”没有属性“0”
【发布时间】:2012-08-14 02:08:03
【问题描述】:

我正在尝试使用 JSTL 将我的数据显示到 JSP 中,但控制台向我显示 javax.el.PropertyNotFoundException: The class 'java.lang.Integer' does not have the property '0' 我有一个带有 Integer and BigDecimalList<Object> 和我的 JSP 我确实放了

<c:forEach items="${obj}" var="object">
   <tr>
      <td width="10%" class="r1Left">${object[0].id}</td>
   </tr>
</c:forEach>

我的List&lt;Object&gt; 包含 [10, 1278612143.23, 10, 3343443.56, 4, 123.45]

请帮帮我。

【问题讨论】:

    标签: java spring-mvc jstl spring-webflow


    【解决方案1】:

    我想你只是想要${object.id},此时你得到的是对象而不是列表。

    【讨论】:

    • 你绝对不想要[0]。 JSTL foreach 标记使 var 对象成为单个对象,而不是 List 本身。一旦你删除了它,你至少应该得到一个不同的错误。但如果 List 中的对象是整数,.id 将无法工作,因为 Integer 没有 id 属性(没有 getId() 方法)。
    • 也许你只想要 ${object}
    猜你喜欢
    • 2011-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-02
    • 2015-07-08
    • 2017-07-28
    • 2011-07-14
    • 2015-07-29
    相关资源
    最近更新 更多