2013-01-17 36 views
1

我在GlassFish中使用Jersey 1.11.1,我試圖返回一個具有@QueryParam的URI。@Ref和@QueryParam

比如我想返回的URI看起來是這樣的:

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

我有這樣的基本@Ref:

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

,但對我的生活,我不能,如果弄清楚有一種方法可以在其中添加查詢參數。

如果有可能如何?如果它不可能有什麼建議而不是做什麼?

+0

http://stackoverflow.com/questions/9617107/java-jersey-declarative-hyperlinking-ref-annotation-use可能重複 – yegor256

+0

不是重複的 - 我是查詢後的參數?和&。另一個答案只包括路徑/ 1 /類型的東西。 – TofuBeer

回答

1

看起來是不支持作爲尚未: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.