2015-03-30 83 views

回答

0

什么,我所做的是扩展HalJsonCollectionRenderer并覆盖此方法:对于上一个和下一个

protected void writeLinkForCurrentPath(RenderContext context, MimeType mimeType, JsonWriter writer) { 
    final href = linkGenerator.link(uri: context.resourcePath, method: HttpMethod.GET.toString(), absolute: absoluteLinks) 
    final resourceRef = href 
    final locale = context.locale 
    def link = new Link(RELATIONSHIP_SELF, href) 
    link.title = getResourceTitle(resourceRef, locale) 
    link.contentType = mimeType ? mimeType.name : null 

    writeLink(link, locale, writer) 
} 

添加链接在需要时得到呈现。

为了做到这一点,我们需要的是能够在RenderContext中对象的参数进行访问的访问查询字符串PARAMS(context.getArguments())

它工作得很好,是不是太复杂。

但是,如果这是另一种方式,我会很高兴知道。