2017-09-01 65 views
-1

我已經使用spring boot,spring-data創建了一個spring RESTFul web服務。 此url(/ api/products)返回json格式的產品對象列表。如何在html頁面上顯示來自spring rest webservice的產品列表

這是我的倉庫和控制器

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

及以下的所有春天的數據REST服務代碼是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頁面?

+1

你的前端內置了什麼? – Stultuske

+0

還沒有建立,我想學習如何使用和顯示在HTML頁面上。 –

+0

類型取決於您在前端使用的內容。因爲html不是動態的,所以它成爲html的機會相當小。最有可能的是,您將使用jsp,jsf,angular,... – Stultuske

回答

0

我用jquery ajax做了它,datatables也給自己帶來了一些漂亮的外觀

相關問題