我有这样的课程:
public class Poetry {
private String title;
private Author author;
// getters and setters
}
和
public class Author {
private String name;
// getters and setters
}
这就是我引用title
的方式:
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>
答案 0 :(得分:0)
尝试访问作者中的字段,例如${poetry.author.name}