开发者

@Path regex expression in RESTful server

I'm writing a RESTful Java server with CXF framework.

How do I can write a @Path Regular Expression i开发者_高级运维n order to obtain any URI finished in "/action" value?


Not sure if its /action/*, /*/action, or /*/action/* you want?. Anyway here goes:

1) /action/* can be matched by

@Path("/action/{search:.*}")<br>
doStuff(@PathParam("search") List<PathSegment> list)

In this example, a request like GET /action/order/2/price will be served by the doStuff() method where list can be used to get to all the path segments in order/2/price captured by the regular expression.

2) /*/action can be matched by (WARNING untested)

@Path("/{search:.*}/action")
findStuff(@PathParam("search") List<PathSegment> list)

In this example, a request like GET /item/2/action will be served by the findStuff() method where list can be used to get to all the path segments in item/2 captured by the regular expression.

3) /*/action/* Here I believe you are out of luck (feel free to correct me if I am wrong), for further info check this blog post.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜