【发布时间】:2013-04-07 06:22:40
【问题描述】:
我用
<class name="Topic" table="topic">
.......
<set name="replies" inverse="true" lazy="false" cascade="save-update">
<key column="TOPIC_ID"/>
<one-to-many class="Reply"/>
</set>
</class>
我看到回复不为空,并且在topic.replies 中有元素;
Topic topic = topicService.getTopicById(topicId);
ActionContext actionContext = getActionContext();
actionContext.put("topic", topic);
在 JSP 中:
<s:iterator value="#topic.replies">
<s:property value="title"/>
</s:iterator>
没有标题显示。 然后我改变我的代码
Topic topic = topicService.getTopicById(topicId);
ActionContext actionContext = getActionContext();
actionContext.put("replies", topic.getReplies);
在 JSP 中
<s:iterator value="#replies">
<s:property value="title"/>
</s:iterator>
显示title的值。
我不知道为什么标题没有以第一种方式显示。
【问题讨论】:
标签: java hibernate jsp struts2 actioncontext