Jersey Links(hateoas)与QueryParameters结合使用

时间:2018-04-16 11:28:56

标签: java jersey query-parameters

我想要创建一个端点,例如:http://localhost:8080/privacy-preferences?category=6&type=21当我运行这一切时,一切正常,我确实得到了我的Hateoas链接。所以,像:

 preferences": [
        {
        "links": [
        {
        "rel": "self",
        "href": "privacy-preferences"
        },
        {
        "rel": "update",
        "href": "privacy-preferences/3/7",
        "method": "put"
        },
        {
        "rel": "delete",
        "href": "privacy-preferences",
        "method": "delete"
        }
        ],
        "code": 7,
        "enabled": true,
        "name": "some name",
        "category": 3
        }
        ]

当我离开其中一个查询参数时,我收到错误。 网址看起来像: http://localhost:8080/privacy-preferences?category=3

    The error i get:
    javax.el.PropertyNotFoundException: Property 'type' not found on type nl.company.api.privacy.dto.PreferencesDto
    at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:269)
    at javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:221)
    at javax.el.BeanELResolver.property(BeanELResolver.java:356)
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:95)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:63)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
    at org.glassfish.jersey.linking.ELLinkBuilder.getParameterValues(ELLinkBuilder.java:153)
    at org.glassfish.jersey.linking.ELLinkBuilder.buildURI(ELLinkBuilder.java:111)

有人知道如何结合查询参数处理hateoas链接吗?

0 个答案:

没有答案