【发布时间】:2016-12-16 01:44:09
【问题描述】:
我有以下带有@PathParam 的 JAX-RS 方法。
@GET
@Produces(MediaType.APPLICATION_XML)
@Path("collect/{orderItemID}")
public Response collect(@PathParam("orderItemID") String orderItemID) {
System.out.println("Order Item ID: " + orderItemID);
....
}
我希望该方法接受传递给它的任何内容。但是,当我传递以下字符串时,容器 WebLogic 返回 HTTP 404 Not Found。问题出在 ?在字符串的开头。如果我删除 ?,它将被接受,并且 System.out.println() 方法将打印出该值。
?ProductCode=yyy&EntityNo=1234&Name=what&FileReference=xxx
接下来我将@Path 更改为以下值:
@Path("collect/{orderItemID : (.+)?}")
这一次,当我用 ? 传递上述字符串时,不再出现 HTTP 404 Not Found。但是,在该方法内部,System.out.println() 现在会打印 orderItemID 的空白值。
如何指定@Path 以便该方法可以接受任何东西?
【问题讨论】: