프로그래밍/Spring
@RequestParam과 @PathVariable
gguldh
2018. 2. 21. 16:35
@RequestParam: request로부터 query 파라미터 값을 접근하기 위함
@RequestMapping(value="/order", method = RequestMethod.GET) ... @RequestParam(value="id", required=true) String id
GET: http://localhost:8081/order?id=1
optional: defaultValue, name, required, value
@PathVariable: 하나 또는 그 이상의 URL 값이 파라미터로 작동하는 동적URL을 처리함
@RequestMapping(value="/order/{id}", method = RequestMethod.GET) ... @PathVariable("id") String id
GET: http://localhost:8081/order/1