我有類是這樣的:訪問類對象 - thymeleaf
public class Poetry {
private String title;
private Author author;
// getters and setters
}
和
public class Author {
private String name;
// getters and setters
}
,這是這樣,我怎麼是指標題:
th:field="${poetry.title}"
但我怎樣才能引用poetry.author?我得到
Exception evaluating SpringEL expression: "poetry.author"
<body>
<div class="container">
<div th:each="poetry : ${poetries}">
<p th:text="${poetry.title}"></p>
<p th:text="${poetry.content}"></p>
<p th:text="${poetry.author}"></p>
</div>
</div>
</body>
添加模板 –