<!DOCTYPE HTML>
<html>
<head>
<title>Hello</title>
<meta http-equiv="Content-Type" content="text.html; charset=UTF-8"/>
</head>
<body>
Hello
<a href="/hello">hello</a>
</body>
</html>
스프링 부트가 제공하는 Welcome Page 기능
<!DOCTYPE HTML>
<html>
<head>
<title>hello static</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
정적컨텐츠
작성한 화면 그대로를 보여주며 무언가 작동은 불가능합니다!
</body>
</html>
"hello-static.html" 파일은 정적 화면으로 요청시 그대로 화면이 출력이 된다.
thymeleaf을 이용해 동적 페이지 생성
import org.springframework.stereotype.Conrtoller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HelloController {
@GetMapping("/hello")
public String hello(Model model) {
model.addAttribute("data", "hello");
return "hello";
}
}
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymelead.org"/>
<head>
<title>Hello</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<p th:text="'안녕하세요. ' + ${data}" > 안녕하세요. 손님</p>
</body>
</html>