在Json表示中更改PagedResources <t>的名称

时间:2017-08-30 15:05:07

标签: java json spring-boot spring-hateoas

我正在使用spring boot开发一个小的rest api,它返回有关HAL表示中名为 Chapter 的对象的信息并使用分页。

正常的HAL表示需要以下控制器

@RestController
@RequestMapping("/chapters")
public class ChapterController {
@Autowired ChapterRepository chapterRepo;   

@RequestMapping(value="/slice", produces="application/hal+json")
public PagedResources<Chapter> slice(Pageable p, PagedResourcesAssembler assembler){
    Page<Chapter> page = chapterRepo.findAll(p);

    return assembler.toResource(page);
  }
}

将返回以下内容

{  
  "_embedded":{  
  "chapterList":[  
      //list of chapters here
  ]
  },
  "_links":{  
    "self":{  
       "href":"http://localhost:8090/chapters/slice?page=0&size=20"
    }
 },
  "page":{  
  "size":20,
  "totalElements":4,
  "totalPages":1,
  "number":0
  }
}

但有一件事我想改变的是&#34; chapterList&#34;提名。

有办法吗

0 个答案:

没有答案
相关问题