πŸ”™λ’€λ‘œκ°€κΈ°

κΈ°λŠ₯

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";
    }
}

νŠΉμ§•

<aside> πŸ’‘ @RequestMapping("/hello”)처럼 value = 속성을 μƒλž΅ν•΄λ„ μž‘λ™μ—λŠ” μ§€μž₯이 μ—†λ‹€.

</aside>