Is there a way to have query parameter “x” be included in the URL with the default value if it is omitted, because currently what I need to do is the following below and I have to do that for each parameter with a default value; is there a better way to do this? I am using Jersey version 1.12
public Response getResponse(@DefaultValue("test") @QueryParam("x") String x)
UriBuilder uriBuilder = UriBuilder.fromUri(uriInfo.getRequestUri());
uriBuilder = uriBuilder.replaceQueryParam(x);
QueryContext.setUrl(uriBuilder.build().toString());
Thank you
I’m not aware of a standard Jersey way to do this but you could intercept the method with AOP and do something like:
I wasn’t sure what
QueryContextclass was in your code – but you could find that in the method also and perform thesetUrlmethod in the interceptor…