1

I am using Jersey 1.11.1 in GlassFish and I am trying to return a URI that has an @QueryParam.

For example I want the returned URI to look something like:

<bar>http://car.com/star?param=XYZ</bar>

I have the basic @Ref like this:

@Ref(
    resource=Foo.class,
    style = Ref.Style.ABSOLUTE,
    bindings={}
)
@XmlElement
private URI bar;

but for the life of me I cannot figure out if there is a way to add the query param in there or not.

If it is possible how? If it isn't possible any suggestions on what to do instead?

TofuBeer
  • 60,850
  • 18
  • 118
  • 163
  • possible duplication of http://stackoverflow.com/questions/9617107/java-jersey-declarative-hyperlinking-ref-annotation-use – yegor256 Jan 17 '13 at 18:58
  • Not a duplicate - I am after the query params ? and &. The other answer only covers the path /1/ type of thing. – TofuBeer Jan 17 '13 at 19:54

1 Answers1

1

Looks like it is not supported as of yet: http://java.net/jira/browse/JERSEY-6881

The jersey-server-linking module lacks of support for query parameters.

Example:
@Ref(
   value="books?page=${instance.page - 1}",
   condition="${instance.page > 0}",
   style=Style.ABSOLUTE
)
@XmlElement
URI previous;

The ? will be encoded as %3F. So it is not possible to add any query parameters to links generated by the @Ref annotation.
TofuBeer
  • 60,850
  • 18
  • 118
  • 163