私はこの単純なMVCの例で立ち往生しました。私がAppを起動してlocalhost:8080に行ったとき、 "Whitelabel Error Page"が表示され、 "src/main/resources/templates"に "index.html"を作成しました。私はまた、@RequestMapping( "/")をインデックスメソッドに追加します。私は問題を見つけることができません。Springboot Whitelabelエラーページ
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>
エラーページに表示されるメッセージは何ですか?ログにエラーがありましたか? –
ホワイトリストエラーページ このアプリケーションには/ errorの明示的なマッピングがないため、これをフォールバックと見なしています。 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を参照)。より多くのメッセージを参照してください。 –