@Controller
@RequestMapping("/authors")
public class AuthorController {
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public Author getAuthor(
final HttpServletRequest request,
final HttpServletResponse response,
@PathVariable final String id)
{
// Returns a single Author by id
return null;
}
@RequestMapping(value = "/{id}/author-properties", method = RequestMethod.GET)
public AuthorProperties getAuthorProperties(
final HttpServletRequest request,
final HttpServletResponse response,
@PathVariable final String id)
{
// Returns a single Author's List of properties
return null;
}
@RequestMapping // How to map /authors/*/author-properties to this method ????
public List<AuthorProperties> listAuthorProperties(
final HttpServletRequest request,
final HttpServletResponse response)
{
// Returns a single Author's List of properties
return null;
}
}
class Author {
String propertiesUri;
// other fields
}
class AuthorProperties {
String authorUri;
// other fields
}
Basically I need:
- /authors - listing all the authors
- /authors/123 - fetching author by id 123
- /authors/123/author-properties - fetching the AuthorProperties object for a 123 author
- /authors/*/author-properties - fetching List of AuthorProperties for all authors
When I tried
@RequestMapping(value = "/*/author-properties", method = RequestMethod.GET)
It was still mapping /authors/*/author-properties
to getAuthorProperties method with path variable value as "*".