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;
    }
}
相关推荐
月落归舟8 小时前
深入剖析乐观锁背后的原理
java·乐观锁
Peter·Pan爱编程8 小时前
第六篇:VS Code + Continue 插件:开源爱好者的低成本高自由度方案
ide·开源·ai编程
SimonKing9 小时前
OpenCode 在 IDEA 中使用 ACP 协议 VS 直接使用 TUI,哪个编程方式更是你的菜?
java·后端·程序员
NE_STOP9 小时前
Redis--持久化之AOF
java
budingxiaomoli9 小时前
注册中心的其他实现-Nacos
java·spring cloud·微服务
大大大大晴天️9 小时前
Flink技术实践-Flink重启策略选型指南
java·大数据·flink
ffqws_9 小时前
Spring @Transactional 注解详解:从入门到避坑
java·数据库·后端·spring
xuhaoyu_cpp_java9 小时前
单调栈(算法)
java·数据结构·经验分享·笔记·学习·算法
黑夜里的小夜莺9 小时前
黑马点评登录成功后点击【我的】会跳转到登录页面 BUG 修复
java·bug
wuyikeer10 小时前
Java进阶——IO 流
java·开发语言·python