RESTFUL 服务 URL 中的分号会截断其后的字符



我有以下代码作为我的休息服务操作。

@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框架。谢谢。

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

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

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

有一种方法可以通过使用PathSegment作为参数的类型而不是String来实现您想要的:

@PathParam("referenceId) PathSegment id

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

String idValue = id.getPath();

得到m1234;5678.

相关内容

最新更新