小编Kir*_*rby的帖子

Spring HATEOAS&HAL:在_embedded中更改数组名称

我正在尝试使用Spring HATEOAS构建符合HAL的REST API.

在一些摆弄之后,我设法开始工作,大多是预期的.(样本)输出现在看起来像这样:

{
    "_links": {
        "self": {
            "href": "http://localhost:8080/sybil/configuration/bricks"
        }
    },
    "_embedded": {
        "brickDomainList": [
            {
                "hostname": "localhost",
                "port": 4223,
                "_links": {
                    "self": {
                        "href": "http://localhost:8080/sybil/configuration/bricks/localhost"
                    }
                }
            },
            {
                "hostname": "synerforge001",
                "port": 4223,
                "_links": {
                    "self": {
                        "href": "http://localhost:8080/sybil/configuration/bricks/synerforge001"
                    }
                }
            }
        ]
    }
}
Run Code Online (Sandbox Code Playgroud)

我不喜欢"brickDomainList"数组的名称.理想情况下应该说"砖块".我该怎么改变它?

这是产生输出的控制器:

@RestController
@RequestMapping("/configuration/bricks")
public class ConfigurationBricksController {

    private BrickRepository brickRepository;
    private GraphDatabaseService graphDatabaseService;

    @Autowired
    public ConfigurationBricksController(BrickRepository brickRepository, GraphDatabaseService graphDatabaseService) {

        this.brickRepository = brickRepository;
        this.graphDatabaseService = graphDatabaseService;
    }

    @ResponseBody
    @RequestMapping(method …
Run Code Online (Sandbox Code Playgroud)

java spring spring-hateoas

9
推荐指数
1
解决办法
3043
查看次数

春天HATEOAS&HAL:我可以只提供链接,但没有内容?

它在标题中说的是什么.

我想提供只包含"较低"资源链接的根资源.似乎Resource除了HttpEntity想要一个带有某些内容的对象作为他们的类型,那么我怎么才能只提供链接呢?

谢谢.

java spring spring-hateoas

7
推荐指数
1
解决办法
774
查看次数

标签 统计

java ×2

spring ×2

spring-hateoas ×2