Skip to content

Instantly share code, notes, and snippets.

@limingzju
Created May 9, 2015 04:05
Show Gist options
  • Save limingzju/28379ab4d5ed3be90954 to your computer and use it in GitHub Desktop.
Save limingzju/28379ab4d5ed3be90954 to your computer and use it in GitHub Desktop.
spring path variable
@RequestMapping(
value = "/{id}.json",
method = RequestMethod.GET,
produces = "application/json")
@ResponseBody
public Person getDetailsAsJson(@PathVariable Long id) {
return personRepo.findOne(id);
}
@RequestMapping(
value = "/{id}.xml",
method = RequestMethod.GET,
produces = "application/xml")
@ResponseBody
public Person getDetailsAsXml(@PathVariable Long id) {
return personRepo.findOne(id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment