REST 资源命名和@PathVariable 注释

REST Resource Naming & @PathVariable annotation

我正在阅读有关 REST 资源命名的教程...

http://api.example.com/device-management/managed-devices/{id}/scripts/{id}:clone

这是命名最佳实践的示例,但我不知道如何使用 @PathVariable 注释来声明它并区分 {id}{id}:clone

public ResponseEntity<?> clone (
HttpServletRequest request, 
@PathVariable long id, ...) {
..
}

需要通过变量名或者属性value@PathVariable来区分这两个ID,如:

@GetMapping("http://api.example.com/device-management/managed-devices/{idManagedDevice}/scripts/{idScript}"
public ResponseEntity<?> clone (HttpServletRequest request, 
    @PathVariable long idManagedDevice,
    @PathVariable long idScript,
) {
..
}

或者:

@GetMapping("http://api.example.com/device-management/managed-devices/{id}/scripts/{idScript}"
public ResponseEntity<?> clone (HttpServletRequest request, 
    @PathVariable(value="id") long idOfManagedDevice,
    @PathVariable(value="idScript") long idOfScript,
) {
..
}