如何在html页面上显示来自spring rest webservice的产品列表

时间:2017-09-01 07:53:51

标签: java web-services spring-data spring-rest

我使用spring boot,spring-data创建了一个Spring RESTFul Web服务。 此URL(/ api / products)以json格式返回产品对象的列表。

这是我的存储库和控制器的所有spring数据休息服务代码

@RepositoryRestResource
public interface ProductRepository extends PagingAndSortingRepository<Product, Long> {
}

以下是json回复

products: [ 

    {
    description: "some product 1",
    price: 100,
    imageUrl: "image url",
    _links: {
    self: {
    href: "http://localhost:8080/products/1"
    },
    product: {
    href: "http://localhost:8080/products/1"
    }
    }
    },
    {
    description: "some product 2",
    price: 200,
    imageUrl: "image url",
    _links: {
    self: {
    href: "http://localhost:8080/products/2"
    },
    product: {
    href: "http://localhost:8080/products/2"
    }
    }
    }
    ]

Q值。如何在客户端使用此休息路径并以表格格式显示在html页面上?

1 个答案:

答案 0 :(得分:0)

我是使用jquery ajax做的,数据表也提供了一些漂亮的引导程序