Ich benutze Spring Boot mit Thymeleaf und ich versuche auf eine einfache Webseite zuzugreifen. Ich habe keinen Fehler beim Erstellen des Projekts. Nur diese beim Zugriff auf localhost:8080/greeting
:"Keine Nachricht verfügbar" mit Spring Boot/Thymeleaf
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Dec 02 15:36:04 CET 2016
There was an unexpected error (type=Not Found, status=404).
No message available
Ich habe einen Controller:
package controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class UserController {
@RequestMapping("/greeting")
public String user(@RequestParam(value = "name", required = false, defaultValue = "World") String name, Model model){
model.addAttribute("name",name);
return "greeting";
}
}
Ein Haupt:
package boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main (String[] args){
SpringApplication.run(Application.class, args);
}
}
Und eine Webseite:
<!DOCTYPE html>
<html xmlns:th="http://www.themyleaf.org">
<head>
<meta charset="ISO-8859-1"/>
<title>SecondMaven</title>
</head>
<body>
<p th:text="'Hello, '+ ${name} + '!!!!!'" />
</body>
</html>
Mein pom.xml
:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
Ich habe keine Ahnung, was mit meinem Code falsch ist. Ich denke, dass es ein Konfigurationsproblem ist, aber bis jetzt hatte ich kein Glück. Ich würde jede Hilfe danken, danke.
Wo hast du deine 'greeting.html'? –
In src/main/resources/templates. – Chuck