【发布时间】:2019-10-22 18:30:03
【问题描述】:
我正在尝试将 HATEOAS 链接添加到我的 Controller 结果中。 链接创建:
Link link = JaxRsLinkBuilder.linkTo(MainRestService.class)
.slash(this::getVersion)
.slash(LinkMappingConstants.TAXPAYERS)
.slash(taxPayerId)
.slash(LinkMappingConstants.ESTIMATIONS)
.slash(estimationId)
.withSelfRel();
链接本身创建良好,但生成的 JSON 中有多余的条目:
"links": [
{
"rel": "self",
"href": "http://localhost:8080/blablabla",
"hreflang": null,
"media": null,
"title": null,
"type": null,
"deprecation": null,
"template": {
"variables": [
],
"variableNames": [
]
}
}
]
我怎样才能得到这种格式? (不使用属性spring.jackson.default-property-inclusion=NON_NULL)
"links": [
{
"rel": "self",
"href": "http://localhost:8080/blablabla"
}
]
谢谢。
【问题讨论】:
标签: java spring rest spring-boot jax-rs