我是Java web的初學者,我正在使用spring4 mvc和mybatis作爲圖書管理系統。
有兩個表t_book和t_type數據庫BMS在MySQL。
這是書實體:
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
}
這是類型實體:
public class Type {
private Long sortId;
private String sortName;
// getter and setter
}
但在bookDetail.jsp,頁面可以顯示的值$ {book.bookName},$ {book.writer},$ {book.pubDate}等,但不能顯示的值爲$ {book.type.sortName}。
這是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>
爲什麼我不能獲得通過$ {} book.type.sortName .JSP中相關數據的價值?我怎麼才能得到它?
請幫忙! 在此先感謝!
沒有,我也不能得到的$ {} book.type的價值。 – Sherry