3

I have the below code as my restful service operation.

    @GET
    @UnitOfWork
    @Timed(name = "get-requests")
    @Path("/{referenceId}")
    public Response get(@Auth @ApiParam(access = "internal") UserPrincipal user,
            @ApiParam(name = "id", value = "reference ID", required = true)
            @PathParam("referenceId") String id) {
         return Response.ok(id).build();
    }

However, I noticed if I pass in m1234;5678, I get only m1234 returned. I tried @Path("/{referenceId:.*}"), but it doesn't work. I also tried use @Encode at the top of the method to make sure the url is not decoded and then try to replace %3B with ";" in the code. But it seems not working also.

Please note that I cannot use Spring framework. Thanks.

joschi
  • 12,746
  • 4
  • 44
  • 50
Laodao
  • 1,547
  • 3
  • 17
  • 39
  • So , what framework / technology you are using ? jax-rs or others? Please add a tag of that technology to your questions – Ken Chan Sep 14 '19 at 02:46
  • Have you tried all the way mentioned in [this](https://docs.jboss.org/resteasy/docs/1.0.0.GA/userguide/html/_Encoded_and_encoding.html) link? – Saurabh Sep 14 '19 at 05:41

1 Answers1

1

The ; denotes a matrix parameter. Use @MatrixParam to get its value.

See also the answers to this question: URL matrix parameters vs. request parameters

Edit: The key of the matrix parameter would be 5678, the value would be null.

There is a way to get achieve what you want by using PathSegment as the type of the parameter instead of String:

@PathParam("referenceId) PathSegment id

In the body of the method, you can use

String idValue = id.getPath();

to get m1234;5678.