I have a jax-rs service which receives a set of parameters in the path, pathparameters. These parameters may be strings containing values not suitable for urls, so they are urlencoded on the client side using the java.net.UrlEncoder like so:
String param = URLEncoder.encode(o.toString(), "UTF-8");
This is used to build the url supplier/group/param1/param2/param3
. If one of these are changed due to the urlencoding, for instance if it is only a space, the string received on the service is a +
sign.
@GET
@Path("{supplierId}/{groupCode}/{groupId}")
@Produces({MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public SupplierGroup getSupplierGroup(@PathParam("supplierId") BigDecimal supplierId,
@PathParam("groupCode") String groupCode,
@PathParam("groupId") BigDecimal groupId) {
//now groupCode is "+", not " "
}
I would expect jaxrs to automatically decode encoded path params.
EDIT:
Testing a bit more I discovered that when sending using %20
for the space, it is able to decode the param.