Java Magazine, Jan/Feb 2016
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2016 19 web apps request establishes model data and then forwards it to a Thymeleaf template for rendering @ Controller class ReservationMvcController private final ReservationRepository reservationRepository @ Autowired public ReservationMvcController ReservationRepository rr this reservationRepository rr @ RequestMapping method RequestMethod GET value reservations mvc public String renderReservations Model model model addAttribute reservations this reservationRepository findAll find template named reservations return reservations A request to http localhost 8080 reservations mvc ultimately renders an HTML template in the src main resources templates directory It looks like this DOCTYPE HTML html xmlns http www w3 org 1999 xhtml xmlns th http www thymeleaf org head title Reservations title head body H1 Reservations H1 div th each r reservations div b th text r id ID b span th text r reservationName Reservation Name span div div body html The result of this is shown in Figure 4 Many applications might simply deliver REST APIs and serve a client side JavaScript application that connects to those endpoints The assets for such an application would live in the src main resources static directory They will not be processed If youre trying to build a data driven user interface quickly you might use a UI component based approach such as the well regarded open source Vaadin Framework Earlier I selected the Vaadin checkbox in Spring Initializr That selection brings in a third party dependency to support an easy Spring Boot integration with Vaadin Vaadin builds on top of GWT UI components consist of fast responsive transpiled client side JavaScript But in Vaadin apps business state lives on the server Heres a simple Figure 4 The reservations application so far
You must have JavaScript enabled to view digital editions.