๐โ๏ธ QNA ์๋น์ค ๊ธฐ๋ฅ ๊ตฌํ (๋ณต์ต)
1๏ธโฃ ํ๋ก์ ํธ ์์
- ํ๋ก์ ํธ ์์ฑ

- ํจํค์ง ๋ช
๋งค๋ฒ ๋์์์ ๋ณด๋ฉด์ ๋๊ฐ์ด ๋ฐ๋ผ์ณค๋๋ฐ ํผ์ ํด๋ณด๋ฉด์ ๋ช ๋ช ๊ท์น์ด ๊ถ๊ธํด์ ธ์ ์ฐพ์๋ณด์๋ค.
ํจํค์ง ๋ช ์ ๋ค๋ฅธ ํ๋ก์ ํธ์ ๊ตฌ๋ถ๋๋ ๊ณ ์ ๊ฐ์ผ๋ก ์ ์ผํ ๊ฐ์ ๊ฐ์ ธ์ผํ๋ค.
์ผ๋ฐ์ ์ผ๋ก ์๋์ ๊ฐ์ด ์ฌ์ฉํ๋ค.
- com.(ํ์ฌ์ด๋ฆ).(ํ๋ก๊ทธ๋จ์ด๋ฆ) -> com.naver.blog
- com.(ํ์ฌ์ด๋ฆ).(ํ๋ซํผ).(ํ๋ก๊ทธ๋จ์ด๋ฆ) -> com.naver.ios.blog
์ถ๊ฐ๋ก, ์๋ฌธ์๋ก ์์ฑํ๋ ๊ฒ์ ๊ถ๊ณ ํ๋ฉฐ, ํ์ฌ์ด๋ฆ๊ณผ ๋๋ฉ์ธ ์ฃผ์๊ฐ ๊ณ ์ ํ ๊ฐ์ด๋ฏ๋ก ์ด ๋๊ฐ๋ฅผ ํ์ฉํ์ฌ ์ ํ๋ค.

- Spring Web : Web ๊ฐ๋ฐ ์ ํ์
- Spring Boot DevTools : ์ฝ๋ ์์ ์ ์๋ฒ ์ฌ์คํ ์์ด ํ์ธ ๊ฐ๋ฅ (์ฌ์ฉ๋ฒ : https://like099.tistory.com/13)
- Property Defaults
- Automatic Restart
- Live Reload
- Global Settings
- Remote Applicaitons
- Lombok : Getter, Setter, Constructor ์ ๊ณต
- Tymeleaf (<-> JSP) : MVC ๋ชจ๋ธ์์ View ๋ฅผ ๋ด๋น. html, xml,js, css ๋ฑ์ ์ฒ๋ฆฌํ ์ ์๋ ์น ๋ฐ ๋ ๋ฆฝํ ํ๊ฒฝ์์ ์ฌ์ฉ ๊ฐ๋ฅํ java ํ ์ธจ๋ฆฟ ์์ง์ผ๋ก html ํ์ผ์ ๊ฐ์ ธ์์ ํ์ฑํ๊ณ ๋ถ์ํ์ฌ ์ ํด์ง ์์น์ ๋ฐ์ดํฐ๋ฅผ ๋ฟ๋ ค์ค๋ค.
- H2 Database (<-> MySQL) : H2DB์ ๊ฒฝ์ฐ ๋ ๋ฆฝ๋ ํ ์คํธ ํ๊ฒฝ์ ๊ตฌ์ถํ ์ ์๋ค๋ ์ฅ์ ์ด ์์ (RDBMS)
2๏ธโฃ ์ปจํธ๋กค๋ฌ ์์ฑ
@Controller
public class MainController {
@RequestMapping("/")
@ResponseBody
public String ShowMain() {
return "Hello Main";
}
}
3๏ธโฃ GetMapping & PostMapping
@Controller
public class MainController {
@GetMapping("/test")
@ResponseBody
public String showGetTest() {
return """
<h1> GetMapping ์ผ๋ก ๋ค์ด์ด </h1>
<form method="POST" action="/test">
<input type="number" name="age" placeholder="๋์ด๋ฅผ ์
๋ ฅํ์ธ์" />
<input type="submit" value="test ํ์ด์ง์ POST ๋ฐฉ์์ผ๋ก ์ด๋" />
</form>
""";
}
@PostMapping("/test")
@ResponseBody
public String showPostTest(@RequestParam(defaultValue = "0") int age) {
return """
<h1> PostMapping ์ผ๋ก ๋ค์ด์ด </h1>
<h3> ์
๋ ฅ๋ ๋์ด : %d </h3>
""".formatted(age);
}
}


3๏ธโฃ http ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌํ๋ ๋๊ฐ์ง ๋ฐฉ๋ฒ
Spring Boot ์์ html ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌํ๋ ๋ฐฉ๋ฒ์ @RequestParam ๊ณผ @PathVariable ๋ก ํฌ๊ฒ ๋๊ฐ์ง๊ฐ ์๋ค.
(์ ๋ฆฌ ํ์) : https://atoz-developer.tistory.com/111 (์ฐธ๊ณ ์์ )
'TIL ๐' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| TlL 6์ผ์ฐจ (2022.10.14) (0) | 2022.10.14 |
|---|---|
| TIL 5์ผ์ฐจ (2022.10.13) (0) | 2022.10.13 |
| TIL 4์ผ์ฐจ (2022.10.12) (0) | 2022.10.12 |
| TIL 3์ผ์ฐจ (2022.10.11) (0) | 2022.10.11 |
| TIL 2์ผ์ฐจ (2022.10.07) (0) | 2022.10.07 |