src -> main -> static ์์ htmlํ์ผ์ ํ๋ ๋ง๋ค์ด ์ค ๊ฒ์ด๋ค.
๊ทธ๋ฌ๋ฉด
localhost:8080 ์ผ๋ก ์ ์ํ๋ฉด hello๊ฐ ๋ฌ๋ค.
+) 80ํฌํธ๋ http์น์๋ฒ ํฌํธ์ด๊ณ , ๋ณดํต 80๋ฒ ํฌํธ๋ฅผ ํ ์คํธํ๋ ๊ฒฝ์ฐ 8080์ ์ด๋ค.
ํ์ง๋ง ๋ด๊ฐ ์ด ๊ฒ ๊ทธ๋๋ก ์๋ฒ์ ์ฌ๋ฆฌ๊ณ ์ถ์ง ์์ ์๋ ์๋ค. ๋์ ์ผ๋ก ์นํ์ด์ง๊ฐ ๋์ํ๊ฒ ํ๊ณ ์ถ์ผ๋ฉด
ํ ํ๋ฆฟ ์์ง์ ์จ์ผ ํ๋ค. Thymeleaf๋ผ๋ ํ ํ๋ฆฟ ์์ง์ ์จ๋ณผ ๊ฒ์ด๋ค.
Thymeleaf
Integrations galore Eclipse, IntelliJ IDEA, Spring, Play, even the up-and-coming Model-View-Controller API for Java EE 8. Write Thymeleaf in your favourite tools, using your favourite web-development framework. Check out our Ecosystem to see more integrati
www.thymeleaf.org
controller ํจํค์ง๋ฅผ ๋ง๋ค์ด์ ๊ทธ ์๋์ HelloController ํด๋์ค๋ฅผ ๋ง๋ค์ด์ค ๊ฒ์ด๋ค.
๐ Controller๋ ๋ฌด์์ผ๊น?
์ฌ์ฉ์๊ฐ ํ๋ฉด์์ ์ ๋ ฅ์ด๋ ์ด๋ค ์ด๋ฒคํธ๋ฅผ ํ์ ๊ฒฝ์ฐ ๊ทธ ์ด๋ฒคํธ์ ๋ง๋ ํ๋ฉด์ด๋ ๋น์ฆ๋์ค ๋ก์ง์ ์คํํ ์ ์๋๋ก ์ ๋ฐ์ดํธ ํด์ฃผ๋ ์ญํ ์ ํ๊ณ ์๋ค.
templateํด๋ ์๋์๋ ์๋์ ๊ฐ์ด ์จ์ค๋ค.
get๋ฐฉ์์ผ๋ก ๋์ด์ค๋ฉด GetMapping์ ํตํด localhost:8080/hello๋ก ๋์ด๊ฐ๊ณ hello๋ฉ์๋๊ฐ ์คํ๋๋ค.
model์ hello!!๋ผ๋ data๋ฅผ ๋ฃ์ด์ค๋ค. ๊ทธ๋ฆฌ๊ณ return์ ์ด๋ฆ์ด hello์ด๋ค. ์๋ resources -> templateํด๋์ hello.html์ ์ฐ๊ฒฐ๋๋ค.
return 'hello'์ฒ๋ผ ์ปจํธ๋กค๋ฌ์์ ๋ฆฌํด๊ฐ์ผ๋ก ๋ฌธ์๋ฅผ ๋ฐํํ๋ฉด viewResolver๊ฐ ํ๋ฉด์ ์ฐพ์์ ์ฒ๋ฆฌํ๋ค. ์คํ๋ง๋ถํธ ํ ํ๋ฆฟ์์ง ๊ธฐ๋ณธ viewName์ ๋งคํํ๋ค.
resources/templates/ + {ViewName} +.html ์ด ์ด๋ฆฐ๋ค.
hello.html์์ ${data}๋ HelloController.java model์ key๊ฐ์ด๋ค.
++) ์ถ๊ฐํ์ต : get๊ณผ post์ ์ฐจ์ด
https://noahlogs.tistory.com/35
[๋คํธ์ํฌ] get ๊ณผ post ์ ์ฐจ์ด
GET ๊ณผ POST ๋ HTTP ๋ฉ์๋๋ก ํด๋ผ์ด์ธํธ์์ ์๋ฒ๋ก ๋ฌด์ธ๊ฐ๋ฅผ ์์ฒญํ ๋ ์ฌ์ฉํ๋ค. 2019/06/01 - [IT ์ ๋ณด ๋ก๊ทธ์บฃ/CS] - [๋คํธ์ํฌ] http ๋ [๋คํธ์ํฌ] http ๋ ๊ธฐ๋ณธ์ ์ผ๋ก ๋คํธ์ํฌ ํต์ ์ ํ ๋ ์ฒ์ ์ ํ
noahlogs.tistory.com
๋น๋ํ๊ธฐ
./gradlew.bat build
cd build/libs
java -jar (ํ๋ก์ ํธ ์ด๋ฆ)-0.0.1-SNAPSHOT.jar
https://computer-science-student.tistory.com/420
[์คํ๋ง ๋ถํธ, Spring Boot] ์๋์ฐ(windows)์์ ๋น๋(build)ํ๊ณ ์คํ
Spring Boot ์๋์ฐ(windows)์์ ๋น๋(build)ํ๊ณ ์คํ 1. ์คํ๋ง ๋ถํธ ํ๋ก์ ํธ๊ฐ ์๋ ํด๋์์ cmd ์ฐฝ ์ด๊ธฐ (๋ฌผ๋ก cmd์ฐฝ์ ์ด๊ณ ์คํ๋ง ๋ถํธ ํ๋ก์ ํธ๊ฐ ์๋ ๊ฒฝ๋ก๋ก ์ด๋ํด๋ ๋จ) 2. cmd์ฐฝ์ gradlew build
computer-science-student.tistory.com
์ ์๋๋ค๋ฉด
gradlew clean build
ํ๋ฉด ๊ธฐ์กด์ buildํ๋ ํด๋๋ฅผ ์ญ์ ํจ๊ณผ ๋์์ ๋น๋๊ฐ ๋๋ค.
'Springboot > lecture' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[springboot] ์คํ๋ง ๋น๊ณผ ์์กด๊ด๊ณ (0) | 2022.08.02 |
---|---|
[springboot] ํ์ ์๋น์ค ๊ฐ๋ฐ (0) | 2022.08.01 |
[spring] ํ ์คํธ ์ฝ๋ ์์ฑํ๋ ๋ฐฉ๋ฒ (0) | 2022.07.26 |
[spring] ์ ์ ์ปจํ ์ธ , MVC์ ํ ํ๋ฆฟ ์์ง , API (0) | 2022.07.26 |
[Spring] ํ๋ก์ ํธ ์์ฑํ๊ธฐ (Gradle vs. Maven / ํ ํ๋ฆฟ์์ง) (0) | 2022.07.26 |