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;
    }
}
相关推荐
tellmewhoisi8 分钟前
java8 List常用基本操作(去重,排序,转换等)
java·list
都叫我大帅哥38 分钟前
TOGAF应用架构阶段全解析:从理论到Java代码实战
java
Amagi.1 小时前
Java设计模式-建造者模式
java·设计模式·建造者模式
EmpressBoost1 小时前
谷粒商城170缓存序列化报错
java·spring·缓存
fouryears_234171 小时前
@PathVariable与@RequestParam的区别
java·spring·mvc·springboot
wxjlkh1 小时前
powershell 批量测试ip 端口 脚本
java·服务器·前端
萌新小白的逆袭2 小时前
《Maven 核心基础笔记(第一天)》
java·开发语言·spring
一念&2 小时前
Java泛型
java
掉鱼的猫2 小时前
Solon 整合 LiteFlow 规则引擎:概念与实战
java·workflow
她说..2 小时前
Stream API流学习总结
java