How to loop and retrieve value from HATEOAS _link attribute (e.g. retrieve a description)?

前端 未结 1 1787
没有蜡笔的小新
没有蜡笔的小新 2021-01-26 18:17

tl;dr

My code gets an array of javascript/json objects from a Restful GET. How do I write code to loop and retrieve, for display, a description (or

1条回答
  •  借酒劲吻你
    2021-01-26 18:54

    Spring Projection

    @Projection(name = "dummyNameForProjection", types = { Product.class })
    public interface VirtualProjection {
    
    // this will get the attribute name from the product entity
    String getProductName();
    
    //this will get the name of the category entity related to the product
    @Value("#{target.category.name}") 
    String getCategoryName();
    

    }

    Just include projection name in your request ex: /products?projection=dummyNameForProjection

    0 讨论(0)
提交回复
热议问题