This is my code, even if i used href with the tag in the list there isn't the link.
Html code:
<ul>
<li th:each="author : ${authors}">
<a th:href="@{ '/author' + '/' + ${author.id} }"
th:text="${author.firstname} + ' ' + ${author.lastname}"></a>
</ul>
My controller:
@RequestMapping(value="/author/{id}", method=RequestMethod.GET)
public ModelAndView getAuthor(@PathVariable("id") Long id) {
ModelAndView m = new ModelAndView();
if (id != null) {
Author a = this.authorService.authorPerId(id);
m.addObject("author", a);
} else {
m.addObject("author", new Author());
}
m.setViewName("author/get");
return m;
}
Aucun commentaire:
Enregistrer un commentaire