I came across the following post at
Handling multiple parameters in a URI (RESTfully) in Java
and i was just curious is the following a valid resource ??
@Path("Client/{client}/users")
public class UserPage
{
@GET
@Produces(MediaType.TEXT_HTML)
public String userChoice(@PathParam(value = "client") final String client)
{****Method here which handles a list of 'users'****}
@GET
@Path("{name}")
@Produces(MediaType.TEXT_HTML)
public String userPage(@PathParam(value = "client") final String client, @PathParam(value = "name") final String name)
{****Method here which handles 'user' information****}}
I especially am curious about the {name} method what uri would call the userpage method ?
how does the {} work here ?? I thought the {} was supose to enclose the name of the path class for example if the path to the class was “/Client” then it should be {client}.
Any suggestions ? IDeas ??
The resource you defined is valid enough, but based on the description of what you are trying to do, you need to change the source to look more like as shown below:
Assuming a root URI http://www.example.com:8080, then the following hold true:
call the
userChoicemethod on the resource implementation class.The value of
clientwill be 10.will call the
userPagemethod on the resource implementation class.The value of
clientwill be 10 and the value ofnamewill be Bob.The curly brace syntax is used to enclose a regular expression that defines the path parameter value. Also, note that I included a leading slash (‘/’) on your class level path – omitting it will cause the paths not to match (in most cases).