IDEA前端thymeleaf只显示部分数据库问题

只显示int类型的number,不显示string类型的price和weight

先看一下apple.html

复制代码
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>User List</title>
</head>
<body>
<h1>User List</h1>

<table>
    <tr>
        <th>ID</th>
        <th>Name</th>
    </tr>
    <tr th:each="item: ${apple}">
        number: <td th:text="${item.number}"></td>
        price: <td th:text="${item.price}"></td>
        weight: <td th:text="${item.weight}"></td>
    </tr>
</table>
</body>
</html>

再在IDEA中验证下是否能查询

可以查询到,那么就是po.Apple的类型设置错误

复制代码
package com.appledashboard.po;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor

public class Apple {
    @Getter
    private Integer number;
    private String price;
    private String weight;
    public void setNumber(Integer number) {
        this.number = number;
    }

    public void setPrice(String price) {
    //错误: return price
        this.price = price;
    }

    public void setWeight(String weight) {
     //错误: return weight
        this.weight = weight;
    }
}
相关推荐
PEI0421 分钟前
MVCC(多版本并发控制)
java·开发语言·数据库
半夏陌离1 小时前
SQL 实战指南:电商订单数据分析(订单 / 用户 / 商品表关联 + 统计需求)
java·大数据·前端
我真的是大笨蛋1 小时前
K8S-Pod(上)
java·云原生·容器·kubernetes
纪元A梦2 小时前
贪心算法应用:数字孪生同步问题详解
java·算法·贪心算法
Micrle_0072 小时前
java分布式场景怎么实现一个高效的 读-写锁
java·分布式
海上生明月丿2 小时前
微服务01
java·spring boot·微服务
coooliang3 小时前
【鸿蒙 NEXT】V1迁移V2状态管理
java·前端·harmonyos
Luke Ewin3 小时前
FunASR的Java实现Paraformer实时语音识别 | 一款无需联网的本地实时字幕软件
java·人工智能·语音识别·asr·funasr·paraformer·sensevoice