我可以在查询参数中使用Map吗? 我有很多REST资源,我想在一个地方更改查询参数列表,我有这样的来源:
@GET
@Path("...")
@Produces({MediaType.APPLICATION_JSON})
public String getPath(
@PathParam("...") String path,
@QueryParam("headers") Map<String, String> headers // error!
如何使用查询参数的动态列表?因为标题将来会改变
答案 0 :(得分:0)
从Oracle extracting request parameters上的文档中,您应该能够使用@Context
注释将标头传递到您的方法中:
@GET
@Path("...")
@Produces({MediaType.APPLICATION_JSON})
public String getPath(
@PathParam("...") String path,
@Context HttpHeaders headers) {
...
然后通过HttpHeaders实例上的方法访问标头和Cookie。我没有试过这个,但它看起来应该有效。