Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Can';在Thymeleaf中找不到字段(自定义POJO列表)?_Spring_Thymeleaf - Fatal编程技术网

Spring Can';在Thymeleaf中找不到字段(自定义POJO列表)?

Spring Can';在Thymeleaf中找不到字段(自定义POJO列表)?,spring,thymeleaf,Spring,Thymeleaf,我有下面的代码。当我调试Thymeleaf的内部时,Thymeleaf无法解析“orderDetails”,尽管该字段存在/不为空 Exception=在类型为的对象上找不到字段或属性“orderDetails” <div th:each="order : ${orders}"> <table> <tr> <th>CUSTOMER</th> <th>PRICE</th>

我有下面的代码。当我调试Thymeleaf的内部时,Thymeleaf无法解析“orderDetails”,尽管该字段存在/不为空

Exception=在类型为的对象上找不到字段或属性“orderDetails”

<div th:each="order : ${orders}">
 <table>
      <tr>
        <th>CUSTOMER</th>
        <th>PRICE</th>
        <th>TIME ORDER PLACED</th>
        <th>ITEMS</th>
      </tr>

      <tr>
        <td th:text="${order.customerAccount.email}">email</td>
        <td th:text="${order.baseCost}">2.50</td>
        <td th:text="${order.tip}">2.00</td>
        <td th:text="${order.orderDetails}">2.00</td>
       <!--  <td th:text="${#lists.size(order.orderDetails)}">1</td> -->
      </tr>

    </table>

     <table>
      <tr>
        <th>DRINK NAME</th>
        <th>AMOUNT</th>
        <th>QUANTITY</th>
        <th>COST</th>
      </tr>

      <tr th:each="orderDetail : ${order.orderDetails}">
        <td th:text="${orderDetail.barStock.drink.name}">Test Drink Name</td>
        <td th:text="${orderDetail.barStock.amount}">10oz</td>
        <td th:text="${orderDetail.quantity}">2</td>
        <td th:text="${orderDetail.barStock.cost * orderDetail.quantity}">2.00</td>
      </tr>

    </table>

顾客
价格
时间顺序
项目
电子邮件
2.50
2
2
酒名
数量
量
成本
测试饮料名称
10盎司
2.
2
这是“订单”字段/类的相关字段

@OneToMany(fetch = FetchType.EAGER, mappedBy = "barOrder")
@JsonProperty
private Set<OrderDetail> orderDetails;
@OneToMany(fetch=FetchType.EAGER,mappedBy=“barOrder”)
@JsonProperty
私人设置订单详细信息;

需要orderDetails字段的公共getter方法来允许Thymeleaf访问它

public Set<OrderDetail> getOrderDetails() {
  return orderDetails;
}
public Set getOrderDetails(){
退货订单详情;
}

是否有orderDetails字段的公共getter方法?/facepalm。。。Noooooo:X觉得可以把它作为一个答案,这样我就可以给你信用了。我已经把我的评论作为一个答案发布了。