1

I use Jersey's Link Headers feature to create HTTP link headers:

@InjectLink(value="users/?orgId=12345&page=0",rel="first")

Works well except question mark - this is encoded in %3F and resulting URL looks like: http://localhost:8080/app/users/%3ForgId=12345&page=0

I there any way to prevent encoding and leave question mark char as is?

2 Answers2

1

It is not suitable case for @InjectLink(value). The URL parameter building should be used by @InjectLink(method, bindings...).

For example:

@InjectLink(
  resource = UserResource.class,
  method ="getUserById", 
  bindings ={@Binding(name = "orgId", value = "${instance.orgId}")},
  style =  Style.ABSOLUTE,
  ... )

And target Jersey resource UserResource.java:

@Path("users/{orgId}") 
public User getUserById(@PathParam("orgId") String orgId) {...}
卢声远 Shengyuan Lu
  • 31,208
  • 22
  • 85
  • 130
0

question mar is url encoded for query params string, so its normal to have %3 in your path. Try using 'bindings' or puting @Queryparams like this How to force URIBuilder.path(...) to encode parameters like "%AD"? This method doesn't always encode parameters with percentage, correctly

Community
  • 1
  • 1
Adrien
  • 365
  • 3
  • 9