我有类是这样的:访问类对象 - 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>
添加模板 –