私はこのRESTリソースを持っている:例えば、6576/M982
:スラッシュ文字を含む文字列パスパラメータを渡すにはどうすればよいですか?
@GET
@Path("{business},{year},{sample}")
@Produces(MediaType.APPLICATION_JSON)
public Response getSample(
@PathParam("business") String business,
@PathParam("year") String year,
@PathParam("sample") String sampleId {
Sample sample = dao.findSample(business, year, sampleId);
return Response.ok(sample).build();
}
sample
paramがスラッシュ文字を含めることができます。
私はhttp://ip:port/samples/2000,2006,6576/M982
と呼んでいますが、明らかに機能しません。
スラッシュを%2F
としてエンコードしたhttp://ip:port/samples/2000,2006,6576%2FM982
でも試しましたが、どちらも機能しません。エンドポイントには届きません。
EDIT
私は、エンドポイントを呼び出すためにレトロフィットを使用していると私はこれを行う:encoded = true
で
@GET("/samples/{business},{year},{sampleId}")
Observable<Sample> getSampleById(
@Path("business") String business,
@Path("year") String year,
@Path(value = "sampleId", encoded = true) String sampleId);
、まだ動作していません。
あなたは 'URLEncode'する必要があります。 – EJP
'@GET("/samples/{business}%2C {year}%2C {sampleId} ")'を試したことがありますか? –