3

我有以下代码作为我的宁静服务操作。

    @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();
    }

但是,我注意到如果我通过m1234;5678,我只会被m1234退回。我试过@Path("/{referenceId:.*}")了,但它不起作用。我还尝试@Encode在方法的顶部使用以确保 url 未被解码,然后尝试%3B用“;”替换 在代码中。但它似乎也不起作用。

请注意,我不能使用 Spring 框架。谢谢。

4

1 回答 1

1

;表示矩阵参数。用于@MatrixParam获取其值。

另请参阅此问题的答案:URL 矩阵参数与请求参数

编辑:矩阵参数的5678,值是null

有一种方法可以通过使用PathSegment作为参数的类型而不是String

@PathParam("referenceId) PathSegment id

在方法的主体中,您可以使用

String idValue = id.getPath();

得到m1234;5678.

于 2019-09-14T08:14:34.273 回答