状況・実現したいこと
spring bootを使用して、Controllerからviewへ画面遷移させたいのですが、"Whitelabel Error Page"となってしまいます。
404の為、Mappingが上手くいっていないと考えておりますが、どこが間違っているのか見当もつかない状態です。
試した事
1).@RestControllerを使用して単純な文字列をreturnする場合は、問題無く表示できる事を確認しています。
2).thymeleafのクラスパスや、html側のxmlns及びタグを付け外ししてみましたが、変化ありません。
3).画面の指示通り、ErrControllerとerror.htmlを作成してみましたが、今度はステータス"500"のエラーとなってしましました。
4).エントリポイントクラスと、Controllerの配置が同一パッケージである事は確認しており、Contorollerを子パッケージに入れてみましたが効果ありませんでした。
5).Eclipseエディタ上で、コード自体のエラーや警告はありません。
"localhost:8080/"アクセス時コンソール出力
2019-03-20 02:24:40.382 INFO 13048 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-03-20 02:24:40.382 INFO 13048 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-03-20 02:24:40.388 INFO 13048 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 6 ms
コード
java
1package com.example.dev; 2import org.springframework.stereotype.Controller; 3import org.springframework.ui.Model; 4import org.springframework.web.bind.annotation.RequestMapping; 5 6@Controller 7public class HelloWorldController { 8 @RequestMapping("/") 9 public String helloWorld(Model model){ 10 model.addAttribute("message","Hello World!"); 11 return "index"; 12 } 13}
html
1<!DOCTYPE html> 2<html xmlns:th="http://www.thymeleaf.org"> 3<head> 4<meta charset="UTF-8"> 5<title>Insert title here</title> 6</head> 7<body> 8 <span th:text="${message}">あああ</span> 9</body> 10</html>
pom
1<?xml version="1.0" encoding="UTF-8"?> 2<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 <parent> 6 <groupId>org.springframework.boot</groupId> 7 <artifactId>spring-boot-starter-parent</artifactId> 8 <version>2.1.3.RELEASE</version> 9 <relativePath/> <!-- lookup parent from repository --> 10 </parent> 11 <groupId>com.example.dev</groupId> 12 <artifactId>bikeEC</artifactId> 13 <version>0.0.1-SNAPSHOT</version> 14 <name>bikeEC</name> 15 <description>Demo project for Spring Boot</description> 16 <properties> 17 <java.version>1.8</java.version> 18 </properties> 19 <dependencies> 20 <dependency> 21 <groupId>org.springframework.boot</groupId> 22 <artifactId>spring-boot-starter-web</artifactId> 23 </dependency> 24 25 <dependency> 26 <groupId>org.springframework.boot</groupId> 27 <artifactId>spring-boot-starter-test</artifactId> 28 <scope>test</scope> 29 </dependency> 30 <dependency> 31 <groupId>org.springframework.boot</groupId> 32 <artifactId>spring-boot-starter-thymeleaf</artifactId> 33 </dependency> 34 </dependencies> 35 36 <build> 37 <plugins> 38 <plugin> 39 <groupId>org.springframework.boot</groupId> 40 <artifactId>spring-boot-maven-plugin</artifactId> 41 </plugin> 42 </plugins> 43 </build> 44</project>
環境
・Eclipse2017 ver4.10.0
・Spring Boot 2.1.3
・Thymeleaf 2.1.3

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/24 13:15
2019/03/25 02:40
退会済みユーザー
2019/03/25 03:23
2019/03/25 09:27
退会済みユーザー
2019/03/25 12:18
2019/03/25 12:40
2019/03/26 13:39
2019/03/30 03:30