Apart from @IanRoberts's suggestion, you could make use of the @Encoded
annotation to get to the original undecoded value of you parameter (by default Jersey decodes the values and that's why id+ASC
becomes id ASC
in your code).
The following example retrieves the decoded value as for the default behavior:
@GET
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response test(@QueryParam("sort") String sort) {
// sort is "id ASC"
return Response.ok().entity(sort).build();
}
To change the behavior you just add @Encoded
:
@GET
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response test(@QueryParam("sort") @Encoded String sort) {
// sort is "id+ASC"
return Response.ok().entity(sort).build();
}