I'm a beginner in Java web.I am using spring4 mvc and mybatis for the book manage system.
There are two tables t_book and t_type in database bms in mysql.
This is the Book entity:
public class Book {
private Long bookNum;
private String bookName;
private String writer;
private String callNumber;
private BigDecimal price;
private String pubCompany;
private Date pubDate;
private Long totalNum;
private Long currentNum;
private String brief;
private Type type; // the associated class
// getter and setter
}
This is the Type entity:
public class Type {
private Long sortId;
private String sortName;
// getter and setter
}
But in the bookDetail.jsp,the page can show the value of ${book.bookName},${book.writer},${book.pubDate} and so on,but cannot show the value of ${book.type.sortName}.
This is a part of bookDetail.jsp:
<table class="table table-bordered table-striped">
<tr>
<th>Book ID</th>
<td>${book.bookNum}</td>
</tr>
<tr>
<th>Book name</th>
<td>${book.bookName}</td>
</tr>
<tr>
<th>Book writer</th>
<td>${book.writer}</td>
</tr>
<tr>
<th>callNumber</th>
<td>${book.callNumber}</td>
</tr>
<tr>
<th>sort</th>
<td>${book.type.sortName}</td>
</tr>
<tr>
<th>publish Date</th>
<td><fmt:formatDate value="${book.pubDate}" pattern="yyyy-MM-dd"/></td>
</tr>
</table>
Why I can't get the value of associated data through ${book.type.sortName} in .jsp? How can I get it?
Please help! Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire