JAX-RS未设置正确的http状态代码

时间:2013-12-13 21:28:48

标签: java rest

REST服务(实现 - Apache-cxf)api url是

  

/客户/ {客户ID}

@GET
@Path("/{customerId}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getCustomer(@PathParam("customerId") Long customerId) throws Exception {

}

customerId是Long类型但是如果我传递字符串,它会抛出404异常,而我期望服务抛出400异常。我是否必须明确设置http状态代码? JAX-RS不会这样做吗?

0 个答案:

没有答案
相关问题