前提・実現したいこと
初歩的なことですが、教えていただきたいです。
SpringBootを使って、htmlを表示させたいです。
@Controllerと@RequestMappingを使っています。
マッピングの位置は違っていないはずですが、ファイルが見つからず、表示されません。
発生している問題・エラーメッセージ
http://localhost:8080/をうつと、404が返ってきます。
該当ページがない旨のエラーであると認識しています。
該当のソースコード
特に処理などはないです。
java
1import static org.springframework.web.bind.annotation.RequestMethod.*; 2import org.springframework.stereotype.Controller; 3import org.springframework.web.bind.annotation.RequestMapping; 4 5@Controller 6public class MyBootAppController { 7 @RequestMapping(value = "/", method = { GET, POST }) 8 public String menu() { 9 return "index"; 10 } 11}
index.html
html
1<!DOCTYPE html> 2<html lang="ja" xmlns:th="http://www.thymeleaf.org"> 3<head> 4<meta charset="UTF-8"> 5</head> 6<body> 7Hello World! 8</body> 9</html>
properties
1#============== 2# thymeleaf 3#============== 4 5spring.thymeleaf.mode=HTML 6spring.thymeleaf.cache=false
試したこと
@RequestMappingのカッコの中に
①("/")
②({"/"})
③value=("/")
を入れて試しました。
第一歩で躓いてしまいました。
宜しくお願い致します。
追記です
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 6 <groupId>com.tuyano.springboot</groupId> 7 <artifactId>MyBootApp</artifactId> 8 <version>0.0.1-SNAPSHOT</version> 9 <packaging>jar</packaging> 10 11 <name>MyBootApp</name> 12 <description>sample project for Spring Boot</description> 13 14 <parent> 15 <groupId>org.springframework.boot</groupId> 16 <artifactId>spring-boot-starter-parent</artifactId> 17 <version>2.0.5.RELEASE</version> 18 <relativePath/> <!-- lookup parent from repository --> 19 </parent> 20 21 <properties> 22 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 23 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 24 <java.version>1.8</java.version> 25 </properties> 26 27 <dependencies> 28 <dependency> 29 <groupId>org.springframework.boot</groupId> 30 <artifactId>spring-boot-starter-web</artifactId> 31 </dependency> 32 33 <dependency> 34 <groupId>org.springframework.boot</groupId> 35 <artifactId>spring-boot-starter-test</artifactId> 36 <scope>test</scope> 37 </dependency> 38 <dependency> 39 <groupId>org.springframework.boot</groupId> 40 <artifactId>spring-boot-starter-thymeleaf</artifactId> 41 </dependency> 42 </dependencies> 43 44 <build> 45 <plugins> 46 <plugin> 47 <groupId>org.springframework.boot</groupId> 48 <artifactId>spring-boot-maven-plugin</artifactId> 49 </plugin> 50 </plugins> 51 </build> 52 53 54</project> 55