cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philipp Leitner <xphili...@gmx.at>
Subject JAX-RS Path Precedence
Date Wed, 02 Jul 2008 09:01:15 GMT
Hi all,

I have a seemingly simple JAX-RS question, but, for some reason, I  
cannot figure it out.

Assume a simple REST order service.

GET /order should return a list of all current orders, while
GET /order/{id} should return the details of the order with the id {id}.

How would I annotate this in JAX-RS / CXF? My simple approach

<snip>

@Path("/")
public class OrderService {
	
	@GET
	@Path(value="/order", limited=true)
	public List<Order> getOrders() {
		....
	}
	
	@GET
	@Path(value="/order/{id}", limited=true)
	public Order getOrder(@PathParam("id") String id) {
		....
	}

}

</snip>

does not seem to work, because the mapping '/order/{id}' seems to  
match both request types from above (and I get a NPE for GET /order).  
Why is this the case? To me this behavior seems counter-intuitive,  
since intuitively @Path(value="/order") seems like a 'better' match  
for GET /order than @Path(value="/order/{id}") ...

Can somebody please shed a light on this?

/philipp

Mime
View raw message