如何在 html 页面上显示来自 spring rest webservice 的产品列表
How to show list of Products coming from spring rest webservice on html page
我使用 spring 引导、spring-数据创建了 spring RESTFul 网络服务。
url(/api/products) returns 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"
}
}
}
]
问。如何在客户端使用此休息路径并将其以表格格式显示在 html 页面上?
我使用 jquery ajax 完成了它,数据表也使用 bootstrap
提供了一些漂亮的外观
我使用 spring 引导、spring-数据创建了 spring RESTFul 网络服务。 url(/api/products) returns 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"
}
}
}
]
问。如何在客户端使用此休息路径并将其以表格格式显示在 html 页面上?
我使用 jquery ajax 完成了它,数据表也使用 bootstrap
提供了一些漂亮的外观