์คํ๋ง๋ถํธ๊ฐ ์ ๊ณตํ๋ Welcome page ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ค
static/index.html์ ์ฌ๋ ค๋๋ฉด Welcome page ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ค.
https://docs.spring.io/spring-boot/reference/web/reactive.html#web.reactive.webflux.welcome-page
thymeleaf ํ ํ๋ฆฟ ์์ง
ํ์๋ฆฌํ ์ฌ์ดํธ : https://www.thymeleaf.org/
- ๋ทฐํ์ด์ง
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.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>
- controller ํจํค์ง ์์ฑ > HelloController ํด๋์ค ์์ฑ
package hello.hello_spring.controller;
import org.springframework.stereotype.Controller;
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!!!");
// data๋ผ๋ ๋ณ์์ hello!!!๋ผ๋ ๊ฐ ๋ฃ์ด์ model๊ฐ์ฒด์ ์ถ๊ฐํจ
return "hello";
// templates/hello.html(Thymeleaf ํ
ํ๋ฆฟ ์์ง ์ฒ๋ฆฌ)
}
}
๋น๋ํ๊ณ ์คํํ๊ธฐ
์ฝ์์ฐฝ(CMD) ์คํ (ํ๋ก์ ํธ๊ฐ C๊ฒฝ๋ก์ ์์ด์ผํ๋ค! D๋ก ํ๋๊น ์๋์..)
C:\>cd C:\SPRINGBOOT\intelliJ\hello-spring
C:\SPRINGBOOT\intelliJ\hello-spring>gradlew
... BUILD SUCCESSFUL ...
C:\SPRINGBOOT\intelliJ\hello-spring>gradlew build
... BUILD SUCCESSFUL ...
C:\SPRINGBOOT\intelliJ\hello-spring>cd build
C:\SPRINGBOOT\intelliJ\hello-spring\build>cd libs
C:\SPRINGBOOT\intelliJ\hello-spring\build\libs>dir
C:\SPRINGBOOT\intelliJ\hello-spring\build\libs>java -jar hello-spring-0.0.1-SNAPSHOT.jar
'๋ฐฑ์๋(Back-End) ๊ฐ๋ฐ > SpringBoot' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SpringBoot] 2.3_API (@ResponseBody) (0) | 2025.02.25 |
---|---|
[SpringBoot] 2.2_MVC์ ํ ํ๋ฆฟ ์์ง (0) | 2025.02.25 |
[SpringBoot] 2.1_์คํ๋ง ์น ๊ฐ๋ฐ ์ ์ ์ปจํ ์ธ (0) | 2025.02.24 |
[SpringBoot] 1.1_์คํ๋ง๋ถํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ (0) | 2025.02.24 |
[SpringBoot] 1.0_์คํ๋ง๋ถํธ ํ๋ก์ ํธ ์์ฑ ๋ฐ ์ธํ ๋ฆฌ์ ์ด ์ค์น (0) | 2025.02.24 |