본문 바로가기

Spring/Springboot

Controller와 HTTP Request 메시지

 

Controller HTTP Sample Request
어노테이션 생략 Sample Code
@PathVariable X
GET http://localhost:8080/hello/request/star/BTS/age/28
@RequestParam O
GET http://localhost:8080/hello/request/from/param?name=BTS&age=28
O
POST http://localhost:8080/hello/request/form/param
Header
Content type: application/x-www.form-urlencoded
Body
name=BTS&age=28
@ModelAttribute O
POST http://localhost:8080/hello/request/form/model
Header
Content type: application/x-www.form-urlencoded
Body
name=BTS&age=28
@RequestBody X
POST http://localhost:8080/hello/request/form/json
Header
Content type: application/json
Body
{"name"=:"BTS", "age":"28"}

@ModelAttribute로 선언한 객체에는 @Setter 선언 필요