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;
    }
}
相关推荐
Refrain_zc18 分钟前
Android 音视频通话核心 —— 音频编码(AAC)完整解析
java
xiaoshuaishuai828 分钟前
C# AvaloniaUI 资源找不到报错
java·服务器·前端·windows·c#
我是唐青枫1 小时前
Java JdbcTemplate 实战指南:用 Spring 轻量完成数据库增删改查
java·数据库·spring
Lumbrologist1 小时前
【C++】零基础入门 · 第 13 节:类与对象基础
java·c++·算法
码不停蹄的玄黓1 小时前
Java 生产者-消费者模型详解
java·开发语言·python
笨蛋不要掉眼泪1 小时前
Java并发编程:Executors框架类深度解析
java·开发语言·并发
南极企鹅2 小时前
深入理解 MVCC:数据库并发控制的基石
java·数据库·mysql
凯瑟琳.奥古斯特2 小时前
力扣1235:加权区间调度最优解
java·python·算法·leetcode·职场和发展
想不到ID了2 小时前
第八篇: 登录注册功能实现
java·javascript
码语智行3 小时前
shp文件生成
java