java jersey variable length paths

三世轮回 提交于 2019-12-11 08:26:20

问题


Is there anyway to specify in jersey I want a variable length paths?

e.g.

I want to implement a jersey resouce that handles e.g. the following url:

/images/asdfu213/size;width=100;height=200/reflect;offset=2/rotate;angle=0.45/

This is a variable length path as the user could append another operation on the image e.g.:

/images/asdfu213/size;width=100;height=200/reflect;offset=2/rotate;angle=0.45/shear;x=0.3/

is there anyway in jersey to implement this?

I have tried:

@Path("/{id}/{size}/{ops: .*}")
Response process(@PathParam("id)String id, @PathParam("size") PathSegment sizeSegment, @PathParam("op") PathSegment opsSegments)

but all the matrix params are striped, and opsSegments.getPath is empty

also tried

@Path("/{id}/{size}/{ops: .*}")
Response process(@PathParam("id")String id, @PathParam("size") PathSegment sizeSegment, @PathParam("op") String opsSegments)

although the path is preserved, all the matrix params are stripped

Any help would be appreciated.


回答1:


Sorry found the answer,

you can have a list of PathSegments like:

process(@PathParam("ops") List<PathSegment> ops)

and jersey is smart enough to handle that for you.

This is in the api doc! should have read it first.



来源:https://stackoverflow.com/questions/8903907/java-jersey-variable-length-paths

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!