问题
I have an endpoint as:
@Path("/products")
@Produces({ MediaType.APPLICATION_JSON })
public interface Products {
@PUT
@Path("/{productId}")
....
}
I have a jax-rs client implemented for this service and have it imported in the another service that I am calling this from.
So I am calling the client as below from my second service
public String updateProduct(String productId){
..
return client.target(this.getBaseUrl()).path("products/").path(productId).request(MediaType.APPLICATION_JSON_TYPE).put(Entity.json(""), String.class);
}
If I have a product with slashes say "control/register app" , the service does not seem to take it well. I did encode the productId before making a call to the service and then decoded it once received. But that doesnt seem to work and I get a 404 not found. Any ideas? Thanks in advance
回答1:
Using @Path("{productId : .+}")
should work.
来源:https://stackoverflow.com/questions/43984969/how-to-allow-slashes-in-path-param-in-jax-rs-endpoint