Error resolving template when running Spring application

Asked

Viewed 1,243 times

1

I’m having trouble running this Spring application, I followed the steps of a booklet, but came up these errors below.

How do I solve this problem?

Mistakes:

Error resolving template "Listadeconvidados", template Might not exist or Might not be accessible by any of the configured Template Resolvers

Follow the pom.xml

 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.algaworks</groupId>
    <artifactId>gestao-festa</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>gestao-festa</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build> 
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

Follows the class Guest Listings:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width" />

    <title>Lista de Convidados</title> 
    <link rel="stylesheet"
        href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
        integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
        crossorigin="anonymous" />
</head>
<body> 

    <h1>Algaworks</h1>

</body>
</html>

Follow the Inviteerscontroller

package com.algaworks.festa.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ConvidadosController { 

     //mapeando para que a requisição cai neste metodo quando for acessar
     //pelo browser
    @RequestMapping("/convidados")  
    public String listar(){  
        return "ListaDeConvidados";  
    } 
}

It follows the class that has the main: Gestaofestaapplication

package com.algaworks.festa;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class GestaoFestaApplication { 

    public static void main(String[] args) { 
        SpringApplication.run(GestaoFestaApplication.class, args);
    }
}

Follow the error image in the browser inserir a descrição da imagem aqui

1 answer

1

Guy found the error. Note that in the control it returns a String, this String is the name of the page that will load. In other words, it has to be the name of the . html file you created. In your case Voce is saying that the name is Listadeconvidados, note that there is a "DE" in the middle of List and Guests, "Listadeconvidados", probably your file . html is under another name! Check there

Browser other questions tagged

You are not signed in. Login or sign up in order to post.