我想公开REST。我想知道使用format查询参数返回资源的格式是什么?在此基础上,选择合适的控制器。
示例:GET /resources/sub-resources?format={valid_formats}&queryParam1={some-selector}........
我想要能做到这一点的东西
@Path("resources/sub-resources")
public interface SubResource {
@GET
Response getSubResourceFormatBase64(@QueryParam("queryParam1") queryParam1);
@GET
Response getSubResourceFormatPlainString(@QueryParam("queryParam1") queryParam1);
}而不是这个
@Path("resources/sub-resources")
public interface SubResource {
@GET
Response getSubResource(@QueryParam("format") format, @QueryParam("queryParam1") queryParam1);
}并在内部选择如何返回格式类型。我怎样才能做到这一点?
注释:格式必须是查询参数
发布于 2020-07-22 15:17:58
为什么不像这样:
@Path("resources/sub-resources")
public interface SubResource {
@GET
@Path("/base64")
Response getSubResourceFormatBase64(@QueryParam("queryParam1") queryParam1);
@GET
@Path("/plainString")
Response getSubResourceFormatPlainString(@QueryParam("queryParam1") queryParam1);
}所以格式应该是路径变量之类的吗?
https://stackoverflow.com/questions/63035806
复制相似问题