问题
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