Spring/Spring 입문
6. 리소스 삭제 DELETE
개발자잡
2022. 6. 30. 14:30
DELETE
package com.example.delete.controller;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api")
public class DeleteApiController {
@DeleteMapping("/delete/{userid}")
public void delete(@PathVariable String userid, @RequestParam String account){
System.out.println(userid);
System.out.println(account);
}
}


Delete는 get과 동작이 비슷하다.
데이터가 있던 없든 요청이 정확하다면 200ok를 돌려준다. 그러므로 멱등하다고 할 수 있다.

따로 dto로 받는다보다 @PathVariable로 일일히 지정하는 것을 권장한다.