Variable length paths java jersey

Do I need to indicate in jersey? I want variable length paths?

eg.

I want to implement a jersey cutting material that processes, for example. 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 can add another operation on the image, for example:

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

In any case, to implement this?

I tried:

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

but all matrix parameters 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 saved, all matrix parameters are deleted

Any help would be appreciated.

+1
source share
1 answer

Sorry, I found the answer,

you can have a PathSegment list, for example:

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

and the jersey is smart enough to handle this for you.

This is in api doc! had to read it first.

+1
source

Source: https://habr.com/ru/post/1416501/


All Articles