如何使用 RESTEasy 制作自定义原子链接?
我想知道是否(如果是,如何)可以使 RESTEasy 返回带有自定义原子链接的对象,例如分页时指向下一页/上一页的链接,特别是我想要得到的是类似于以下内容的内容
<collection>
<start>4</start>
<values>4</values>
<total>20</total>
<item>...</item>
<item>...</item>
<item>...</item>
<item>...</item>
<atom:link rel="next" href="...?page=3"/>
<atom:link rel="previous" href="...?page=1"/>
<atom:link rel="first" href="...?page=1"/>
<atom:link rel="last" href="...?page=5"/>
</collection>
:我已经弄清楚了如何提供用于发现的链接,但是如果可能的话,制作这样的自定义链接似乎更复杂。
I'm wondering if (and if so, how) it's possible to make RESTEasy return an object with custom atom links, such as links to next/previous page when paginating, particularly what I want to get is something akin to the following:
<collection>
<start>4</start>
<values>4</values>
<total>20</total>
<item>...</item>
<item>...</item>
<item>...</item>
<item>...</item>
<atom:link rel="next" href="...?page=3"/>
<atom:link rel="previous" href="...?page=1"/>
<atom:link rel="first" href="...?page=1"/>
<atom:link rel="last" href="...?page=5"/>
</collection>
I've worked out how to give links for discovery, but making custom links like this appears to be more complicated, if at all possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后,我最终使用
元素并创建我自己的元素以插入到 JAXB 对象的任何字段中。 似乎有其自身的问题,但至少又向前迈进了一步。In the end I've ended up using the
<any/>
element and creating my own Elements to insert in to the any field of the JAXB objects. That seems to have its own problems, but at least it's a step further.