@PathVariable


 

path variable values are directly added in the url path

@RequestMapping(value="/{userId}", method=RequestMethod.GET)
public String getUsername(@PathVariable("userId") long userId)
{   
    //code to find username and return it
}

i.e: /home/123
here 123 is the id of the user. It is passed in the userId placeHolder in the value="/{userId}"

here in value="/{userId}" the {userId} is placeholder, the value in it is directly mapped to the long userId varialbe through the @PathVariable("userId").
here the @PathVariable("userId") must be same as the  value="/{userId}".
but as here name of placeholder value="/{userId}" and parameter long 'userId' is same you can ignore to specify the value in the  @PathVariable.
For example:

@RequestMapping(value="/{userId}", method=RequestMethod.GET)
public String getUsername(@PathVariable long userId)
{   
    //code to find username and return it
}