使用springboot遇到的500错误--模板解析错误

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Tue Mar 31 10:50:20 CST 2020
There was an unexpected error (type=Internal Server Error, status=500).
An error happened during template parsing (template: “class path resource [templates/teacher.html]”)

使用spring时 ,获取数据遇到这个错误!找了半天也没发现哪里错了,代码都正常的。

首先我的一张表是teacher表
使用springboot遇到的500错误--模板解析错误
cid指的是course表
使用springboot遇到的500错误--模板解析错误
项目代码:
teacher实体类使用springboot遇到的500错误--模板解析错误
course实体类
使用springboot遇到的500错误--模板解析错误
这里我使用了lombok,可以自行帮我们增加get set 构造方法,具体请百度
使用springboot遇到的500错误--模板解析错误
这是我的controller一个查询数据,一个保存数据。service和实现类及dao层正常写。
这里直接说一下报开头那个错误的原因:
翻译一下:
此应用程序没有针对/ error的显式映射,因此您将其视为后备。

2020年3月31日星期二10:50:20
发生意外错误(类型=内部服务器错误,状态= 500)。
模板解析期间发生错误(模板:“类路径资源[templates / teacher.html]”)
使用springboot遇到的500错误--模板解析错误
这是teacher.xml 文件

解决方法是:

1. 数据库表中不要有null的值。
2. 如果数据库有null值也可以使用这种方法。如果有null值而且是一个实体类用到了另一个实体类(比如我的teacher类里定义了course类)应该在实体类中这样

使用springboot遇到的500错误--模板解析错误
我的问题就是这样解决的,后续也可以正常运行了