简体   繁体   English

在链接到 controller 的简单 HTML 上出现“无法找到 go 的声明”错误

[英]"Cannot find declaration to go to" error on a simple HTML linking to a controller

I'm using Thymeleaf along with Spring Boot to create a CRUD API.我使用 Thymeleaf 和 Spring Boot 来创建一个 CRUD API。

The code below is regarding the creation of a table on a HTML file:下面的代码是关于在 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">

The following is code from the controller class regarding the attribute "titulos" declared above:以下是来自 controller class 关于上面声明的属性“titulos”的代码:

@RequestMapping
public ModelAndView pesquisar() {
    List<Titulo> todosTitulos = titulosRepository.findAll();

    ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject("titulos", todosTitulos);
    return modelAndView;
}

I have no idea why I'm getting the following error:我不知道为什么会出现以下错误:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [titulos], template might not exist or might not be accessible by any of the configured Template Resolvers

Before someone points it out, I'm using xmlns:th="http://www.thymeleaf.org" inside the HTML tag.在有人指出之前,我在 HTML 标签内使用了xmlns:th="http://www.thymeleaf.org"

Turns out I forgot to identify the viewName when creating my modelAndView attribute:原来我在创建 modelAndView 属性时忘记了识别 viewName:

ModelAndView modelAndView = new ModelAndView("PesquisaTitulos");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM