Reputation: 1712
I have below client code:
String filePath = "/testzip/123/TEST-test.zip";
target = mainTarget.path("file").path("{filePath}");
Invocation.Builder invocationBuilder = target
.resolveTemplate("filePath", filePath)
.request(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_OCTET_STREAM);
Response response = invocationBuilder.get();
Below is my server code:
@GET
@Path("{filePath}")
@Produces({MediaType.APPLICATION_OCTET_STREAM})
public Response get(@PathParam("filePath") String filePath) {
File file = new File(filePath);
return Response.status(Response.Status.OK).entity(file).build();
}
This client is throwing Bad Request exception while I send below filePath:
String filePath = "/testzip/123/TEST-test.zip";
But it is working fine when I send below filePath (simple string):
String filePath = "testzip";
I am not able to figure it out why it is not working when forward slash(/) is present in path parameters.
Upvotes: 0
Views: 1427
Reputation: 15275
I believe you cannot have /
in a @PathParam
by default.
EDIT Have a look here : Tomcat, JAX-RS, Jersey, @PathParam: how to pass dots and slashes?
Upvotes: 1