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;
    }
}
相关推荐
云烟成雨TD1 天前
Spring AI Alibaba 1.x 系列【6】ReactAgent 同步执行 & 流式执行
java·人工智能·spring
于慨1 天前
Lambda 表达式、方法引用(Method Reference)语法
java·前端·servlet
swg3213211 天前
Spring Boot 3.X Oauth2 认证服务与资源服务
java·spring boot·后端
gelald1 天前
SpringBoot - 自动配置原理
java·spring boot·后端
殷紫川1 天前
深入理解 AQS:从架构到实现,解锁 Java 并发编程的核心密钥
java
一轮弯弯的明月1 天前
贝尔数求集合划分方案总数
java·笔记·蓝桥杯·学习心得
chenjingming6661 天前
jmeter线程组设置以及串行和并行设置
java·开发语言·jmeter
殷紫川1 天前
深入拆解 Java volatile:从内存屏障到无锁编程的实战指南
java
eddieHoo1 天前
查看 Tomcat 的堆内存参数
java·tomcat
那个失眠的夜1 天前
Mybatis延迟加载策略
xml·java·数据库·maven·mybatis