【问题标题】:Adding nested columns to jstl report by datatables dandelion通过数据表蒲公英将嵌套列添加到jstl报告
【发布时间】:2015-04-14 08:14:31
【问题描述】:

我正在使用蒲公英来显示一个表(来自一个休眠数据库):

<datatables:table id="listPersons" data="${listPersons}" row="person" 
                  cellspacing="0" width="100%"
                  theme="bootstrap2" pageable="true" info="true">
        <datatables:column title="Person" property="person"/>
        <datatables:column title="Car" property="car"/>
</datatables:table>

效果很好。

但是,我需要从父母类(休眠数据库)中添加额外的两列:“父亲姓名”和母亲姓名“。 该类(也休眠)具有变量:Parents parents;

我尝试了类似的方法:

<c:forEach items="${person.parents}" var="parents"> 
    <datatables:column title="Father name" property="parents.father_name"/>
</c:forEach>

但我得到了例外:

javax.servlet.ServletException:javax.servlet.jsp.JspException:java.lang.NoSuchMethodException:类“org.hibernate.collection.internal.PersistentBag”上的未知属性“father_name”

我尝试了很多变体(使用蒲公英数据表),但没有一个有效。

【问题讨论】:

    标签: hibernate spring-mvc datatables jstl dandelion


    【解决方案1】:

    你应该改成

    <datatables:column title="Father name">
        <c:forEach items="${person.parents}" var="parent">
            <c:out value="${parent.father_name}"/>
        </c:forEach>
    </datatables:column>
    

    您遇到的问题是 property="parents.father_name"/&gt; 没有使用您在 forEach 中设置的变量,而是使用了作为集合的休眠实体的 parents 属性

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-30
      • 1970-01-01
      • 1970-01-01
      • 2013-08-08
      • 2016-09-08
      • 1970-01-01
      • 2016-10-16
      相关资源
      最近更新 更多