You can do this using Spring 3.0. Spring 3.0 @PathVariable ability to specify @PathVariable to pull values ββfrom a URL path (previously this was not easy in Spring MVC).
You can also use @RequestMapping to specify the HTTP method (s) that should respond to each method in your controller.
I also use Spring Security to implement the functional key of the API key. This way you can restrict access to your API in a way that REST clients can easily implement. I had to extend org.springframework.web.filter.GenericFilterBean and add an appropriate authentication like this
SecurityContextHolder.getContext().setAuthentication(apiKeyAuth)
source share