2016-12-08 2 views
0

저는 자바 웹 초보자입니다. spring4 mvc와 mybatis를 사용하여 책 관리 시스템을 사용하고 있습니다.

두 테이블 t_book와 MySQL의 데이터베이스 BMS의 t_type있다.

public class Type { 

    private Long sortId; 

    private String sortName; 

    // getter and setter 
} 

그러나 bookDetail.jsp에서

, 페이지 이 값을 표시 할 수 있습니다 :

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 

} 

이것은 유형 엔티티는 다음과 같습니다

실체 $ {book.bookName}, $ {book.writer}, $ {book.pubDate} 등과 같이 표시되지만 의 값을 표시 할 수 없습니다. $ {book.txt.sortName}.

<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> 

가 왜 .jsp로의 {book.type.sortName} $을 통해 관련 데이터의 값을 얻을 수 없습니다

이 bookDetail.jsp의 일부인가? 그것을 어떻게 얻을 수 있습니까?

도와주세요! 미리 감사드립니다.

답변

0

아마도 모델을 Lazy로 가져 오는 것이므로 참조의 가치가없는 첫 번째 부분 만 있으므로 $ {book.type} 유형에 대한 참조 만 제공합니다.

lazyLoadingEnabled="false" 
+0

아니, 나는 또한 $ {book.type}의 값을 얻을 수 없다 : 당신의 SQL 매핑 XML의 – Sherry

0

, 속성을 변경할 수는 다음과 같이 lazyLoadingEnabled.
+0

안녕하세요, 말씀하신대로했으나 작동하지 않았습니다. – Sherry