我坚持使用这个简单的MVC示例。当我启动应用程序并转到localhost:8080时,我得到了“Whitelabel Error Page”,即使我在“src/main/resources/templates”中创建了“index.html”。我还在我的索引方法中添加了@RequestMapping(“/”)。我找不到问题。Springboot白标错误页面
IndexController.java
:
package controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class IndexController {
@RequestMapping("/")
public String index(){
return "index";
}
}
SpringmvcApplication.java
:
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringmvcApplication {
public static void main(String[] args) {
SpringApplication.run(SpringmvcApplication.class, args);
}
}
index.html
- “的src /主/资源/模板” 下:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
<title>Hello Spring MVC</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<h1>Hello World</h1>
<h2>This is my Thymeleaf index page.</h2>
</body>
</html>
它在错误页面上显示什么信息?你有没有看到日志上的任何错误? –
白标签错误页面 此应用程序没有明确的映射/错误,因此您将此视为后备。 Wed May 25 22:55:44 CEST 2016 出现意外错误(type = Not Found,status = 404)。 无可用消息 - 我可以在localhost上看到:8080 – zoram
启用调试(请参阅http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html)以查看更多消息。 –