現在、REST API に新しい機能を追加しようとしています。
基本的に、パスの最後にクエリ パラメーターを追加する機能を追加し、これをたとえばすべてのクエリ オプションのマップに変換したいと考えています。
私の現在のコードでは、次のようなことができます
localhost:8181/cxf/check/
localhost:8181/cxf/check/format
localhost:8181/cxf/check/a/b
localhost:8181/cxf/check/format/a/b
これにより、すべての @pathparam が文字列変数として使用され、応答が生成されます。
私が今やりたいことは、追加することです:
localhost:8181/cxf/check/a/b/?x=abc&y=def&z=ghi&...
localhost:8181/cxf/check/format/a/b/?x=abc&y=def&z=ghi&...
そして、これにより、pathparam と一緒に使用して応答を構築できる Map を生成します。
x => abc
y => def
z => ghi
... => ...
私はこの[下]のようなことを考えていましたが、@QueryParamは1つのキー値のみを処理し、それらのマップを処理していないようです。
@GET
@Path("/{format}/{part1}/{part2}/{query}")
Response getCheck(@PathParam("format") String format, @PathParam("part1") String part1, @PathParam("part2") String part2, @QueryParam("query") Map<K,V> query);
以下は私の現在のインターフェースコードです。
@Produces(MediaType.APPLICATION_JSON)
public interface RestService {
@GET
@Path("/")
Response getCheck();
@GET
@Path("/{format}")
Response getCheck(@PathParam("format") String format);
@GET
@Path("/{part1}/{part2}")
Response getCheck(@PathParam("part1") String part1,@PathParam("part2") String part2);
@GET
@Path("/{format}/{part1}/{part2}")
Response getCheck(@PathParam("format") String format, @PathParam("part1") String part1, @PathParam("part2") String part2);
}