학습 목표
같은 URL 맵핑 이지만 METHOD 방식에 따라서 서버는 구분 할 수 있다.
package com.example.demo2.controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/user")
public class UserController {
// http://localhost:8080/user/info
@GetMapping("/info")
public void info() {
System.out.println("여기는 method get 방식 입니다.");
}
// http://localhost:8080/user/info
@PostMapping("/info")
public void info2() {
System.out.println("여기는 method post 방식 입니다.");
}
// http://localhost:8080/user/info
@PutMapping("/info")
public void info3() {
System.out.println("여기는 method put 방식 입니다.");
}
// http://localhost:8080/user/info
@DeleteMapping("/info")
public void info4() {
System.out.println("여기는 method delete 방식 입니다.");
}
}
'Spring boot' 카테고리의 다른 글
제어의 역전과 의존 주입(Ioc /DI ) (0) | 2023.04.10 |
---|---|
Response 와 MIME TYPE 에 이해 (0) | 2023.04.10 |
DELETE 방식에 이해 및 실습 (0) | 2023.04.10 |
PUT 방식에 이해 및 실습 (0) | 2023.04.07 |
POST 방식에 이해 및 실습 (0) | 2023.04.07 |