HTTP μμ²μ μ²λ¦¬ν λ©μλμ μ΄ μ΄λ Έν μ΄μ μ μ¬μ©νλ©°, μμ² λ©μλλ₯Ό μ§μ ν μ μλ€.
@Controller
public class MyController {
//μ΄λ
Έν
μ΄μ
μ HTTP λ©μλλ₯Ό GETμΌλ‘ μ§μ ν¨
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String helloGet(Model model) {
model.addAttribute("message", "Hello from GET method");
return "hello";
}
//μ΄λ
Έν
μ΄μ
μ HTTP λ©μλλ₯Ό POSTλ‘ μ§μ ν¨
@RequestMapping(value = "/hello", method = RequestMethod.POST)
public String helloPost(Model model) {
model.addAttribute("message", "Hello from POST method");
return "hello";
}
}
@GetMapping, @PostMapping, @PutMapping, @DeleteMapping λ±μ μ΄λ
Έν
μ΄μ
μ μ¬μ©νλ κ²μ΄ λ λͺ
ννκ³ κ°κ²°νλ€.<aside>
π‘ @RequestMapping("/helloβ)μ²λΌ value = μμ±μ μλ΅ν΄λ μλμλ μ§μ₯μ΄ μλ€.
</aside>