MVC ๋? Model, View, Controller
- Controller
package hello.hello_spring.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class HelloController {
@GetMapping("hello-mvc")
public String helloMvc(@RequestParam("name") String name, Model model) {
model.addAttribute("name", name);
return "hello-template";
}
}
- View
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<p th:text="'์๋
ํ์ธ์.' + ${data}"> hello! empty</p>
</body>
</html>

'๋ฐฑ์๋(Back-End) ๊ฐ๋ฐ > SpringBoot' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SpringBoot] 3.1_ํ์ ๋ฆฌํฌ์งํ ๋ฆฌ ๊ตฌํ (0) | 2025.02.25 |
---|---|
[SpringBoot] 2.3_API (@ResponseBody) (0) | 2025.02.25 |
[SpringBoot] 2.1_์คํ๋ง ์น ๊ฐ๋ฐ ์ ์ ์ปจํ ์ธ (0) | 2025.02.24 |
[SpringBoot] 1.2_View ํ๊ฒฝ์ค์ ๋ฐ ๋น๋ํ๊ณ ์คํํ๊ธฐ (1) | 2025.02.24 |
[SpringBoot] 1.1_์คํ๋ง๋ถํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ (0) | 2025.02.24 |