【发布时间】:2021-02-09 00:45:00
【问题描述】:
我正在使用 Thymeleaf 和 Spring Boot 创建一个 CRUD API。
下面的代码是关于在 HTML 文件上创建表格的:
<tr th:each="titulo : ${titulos}" th:value="titulo">
<td class="text-center" th:text="${titulo.codigo}">1</td>
<td class="text-center" th:text="${titulo.descricao}"></td>
<td class="text-center" th:text="${titulo.dataVencimento}"></td>
<td class="text-center" th:text="${titulo.valor}"></td>
<td class="text-center" th:text="${titulo.status.descricao}"></td>
<td class="text-center">
以下是控制器类中关于上面声明的属性“titulos”的代码:
@RequestMapping
public ModelAndView pesquisar() {
List<Titulo> todosTitulos = titulosRepository.findAll();
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("titulos", todosTitulos);
return modelAndView;
}
我不知道为什么会出现以下错误:
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [titulos], template might not exist or might not be accessible by any of the configured Template Resolvers
在有人指出之前,我在 HTML 标记中使用了xmlns:th="http://www.thymeleaf.org"。
【问题讨论】:
标签: java spring api intellij-idea thymeleaf