@Ref和@QueryParam

时间:2013-01-17 06:11:22

标签: jersey jax-rs java-ee-6

我在GlassFish中使用Jersey 1.11.1,我试图返回一个带有@QueryParam的URI。

例如,我希望返回的URI看起来像:

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

我有这样的基本@Ref:

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

但是对于我的生活,我无法弄清楚是否有办法在那里添加查询参数。

如果有可能怎么样?如果不可能有任何关于做什么的建议?

1 个答案:

答案 0 :(得分:1)

截至目前尚未支持:http://java.net/jira/browse/JERSEY-688 1

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.