임은 둘 사이의 다 대다 관계가있다.최대 절전 관계 JSTL 질문
컨트롤러 (발췌) :
List<Person> persons = personManager.getPersons();
Map<String, Object> myModel = new HashMap<String, Object>();
myModel.put("persons", persons);
return new ModelAndView("WEB-INF/jsp/hello.jsp","model",myModel);
를 각 사람은 내가 personinstance.getEvents()을 heres 내가 작업 할 것을
를 사용하여 프로그래밍 방식으로 액세스 할 수는 Person.class의 이벤트 세트가 있습니다
JSP 페이지 :
<%@ include file="include.jsp"%>
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>Persons</h1>
<br />
<c:forEach items="${model.persons}" var="person">
<c:out value="${person.firstname }" />
<c:out value="${person.lastname }" />
<c:forEach items="${person.events }" var="event">
<c:out value="${event.title }" />
</c:forEach>
<br />
</c:forEach>
</html>
오류 :
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: domain.Person.events, no session or session was closed
올바른 방법 (jstl을 사용하는 각 루프에 대해 중첩 됨)을 수행 할 것인지 또는 컨트롤러 또는 무언가를 통해 찾고있는 결과를 얻을 수 있는지 확실하지 않습니다. 하지만 몇 가지 조언이 필요