love kumar
love kumar

Reputation: 131

How to place the multiple table values in thyme-leaf view html file?

I can retrieve the values from multiple tables in database, but in thyme leaf html tags i don't know how to place the retrieved values in view page. Can anyone please give me a sample code using html with thyme leaf tags for showing 2 table values?

(spring mvc, hibernate, MySQL, thyme-leaf)

Upvotes: 0

Views: 1504

Answers (1)

Martin
Martin

Reputation: 94

this is a sample method to pass values form a controller to a template:

public String index(Model model, HttpSession session, HttpServletResponse response, HttpServletRequest req) {
    model.addAttribute("cars", this.cars);
    return "index";
}

This is a possible snippet to access for example a car-list:

<th:block th:each="car: ${cars}">
      <span th:text="${car.name}"/>
</th:block>

Upvotes: 1

Related Questions