Nach Vorkenntnissen ist der Inhalt des obigen Links erforderlich.
Ordnerstruktur
Hello
└─ src
└─ main
├─ java
│ └─ com
│ └─ example
│ └─ demo
│ ├─ HeloController.java
│ └─ HelloApplication.java
└─ resources
├─ application.properties
│
├─ static
└─ templates
└─ index.html
HeloController.java
package com.example.demo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class HeloController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(Model model) {
model.addAttribute("message", "Hello Springboot");
return "index";
}
}
index.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Hello</title>
<meta charset="utf-8" />
</head>
<body>
<h1>Hello World</h1>
<p>
<span th:text="${message}"></span>!!!
</p>
</body>
</html>
[Datei (F)] -> [Neu (N)] -> [Spring Starter Project]
.
HelloController.java
und index.html
sind [oben beschrieben](# 3spring-boot-Create project).
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.125 s
[INFO] Finished at: 2020-07-05T21:50:22+09:00
[INFO] ------------------------------------------------------------------------
Recommended Posts