예) http://cafe.daum.net/sq99/2hq/68443
(sq99:카페아이디, 2hq:게시판이름, 68443:게시물에 이름)
요청 URL : /users/{userid}
파라미터로 처리 : @PathVariable("userid") String userid
@RestController
@RequestMapping("/users")
public class UserController{
@AutoWired
private UserService userService;
@GetMapping("/{userid}")
public User getUser(@PathVariable("userid") String userid){
return userService.getUser(userid);
}
}
@PutMapping("")
public Map<String, Object> updateUser(@RequestParam(value="userid") Integer userid,
@RequestParam(value="username") String username){
Map<String, Object> map = new LinkedHashMap<String, Object>();
userService.updateUser(userid, username);
map.put("result", "updated");
return map;
}
{
"userid": 700,
"username": "김"
}
{
"userid": 300,
"username": "류현진"
}