Nesse trecho aqui, como eu imprimo o Iterable com sysout antes de ir pra view?
@RequestMapping("listaconvidados")
public String listaConvidados(Model model){
Iterable<Convidado> convidados = repository.findAll();
// O sysout vem aqui
model.addAttribute("convidados", convidados);
return "listaconvidados";
}
Porque fiz a mesma coisa mudando os nomes de variaveis e não consigo verificar se está mandando certo pra view
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Dec 17 19:39:02 BRST 2018
There was an unexpected error (type=Internal Server Error, status=500).
An error happened during template parsing (template: "class path resource [templates/list_customer.html]")
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/list_customer.html]") at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241) at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100) at
...
@RequestMapping("/list_customer")
public ModelAndView list_customer() {
customerService.save(new Customer("Jack", "Bauer"));
customerService.save(new Customer("Chloe", "O'Brian"));
customerService.save(new Customer("Kim", "Bauer"));
customerService.save(new Customer("David", "Palmer"));
customerService.save(new Customer("Michelle", "Dessler"));
Iterable<Customer> customers = customerService.findAll();
ModelAndView modelAndView = new ModelAndView("list_customer");
modelAndView.addObject("customers", customers);
return modelAndView;
}
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en"></head>
<body>
<table>
<tr th:each="customer : ${customers}">
<td th:text="${customer.firstName}">Name</td>
<td th:text="${customer.lastName}">Name</td>
</tr>
</table>
</body>
</html>