- 设置全局时间格式,也可以用局部(自行百度)
spring.jackson.date-format=yyyy-MM-dd
spring.jackson.time-zone=GMT+8
- 写一下sql语句(我的数据库是没有“age”这个字段的)
select *,YEAR(from_days(datediff(now(),born_date)))AS 'age' from book_user
- 在你的封装类中中加入age字段
private Integer age;
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
- 你的controller正常写,但时你的前端多一个age属性就可以了